From patchwork Tue Apr 25 01:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orson Zhai X-Patchwork-Id: 98162 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1739521qgf; Mon, 24 Apr 2017 18:46:06 -0700 (PDT) X-Received: by 10.107.53.2 with SMTP id c2mr12345298ioa.185.1493084766568; Mon, 24 Apr 2017 18:46:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si2228528ite.78.2017.04.24.18.46.06; Mon, 24 Apr 2017 18:46:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S979743AbdDYBqF (ORCPT + 16 others); Mon, 24 Apr 2017 21:46:05 -0400 Received: from sci-ig2.spreadtrum.com ([222.66.158.135]:23930 "EHLO SHSQR01.spreadtrum.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S979630AbdDYBp5 (ORCPT ); Mon, 24 Apr 2017 21:45:57 -0400 X-Greylist: delayed 1492 seconds by postgrey-1.27 at vger.kernel.org; Mon, 24 Apr 2017 21:45:56 EDT Received: from SHSQR01.spreadtrum.com (localhost [127.0.0.2] (may be forged)) by SHSQR01.spreadtrum.com with ESMTP id v3P1L4Mj010620; Tue, 25 Apr 2017 09:21:04 +0800 (CST) (envelope-from Orson.Zhai@spreadtrum.com) Received: from ig2.spreadtrum.com (shcas02.spreadtrum.com [10.0.1.202]) by SHSQR01.spreadtrum.com with ESMTP id v3P1KDjj009788 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Tue, 25 Apr 2017 09:20:13 +0800 (CST) (envelope-from Orson.Zhai@spreadtrum.com) Received: from SHCAS02.spreadtrum.com (10.0.1.202) by SHMBX02.spreadtrum.com (10.0.1.204) with Microsoft SMTP Server (TLS) id 15.0.847.32; Tue, 25 Apr 2017 09:20:11 +0800 Received: from localhost (10.0.73.143) by SHCAS02.spreadtrum.com (10.0.1.250) with Microsoft SMTP Server (TLS) id 15.0.847.32 via Frontend Transport; Tue, 25 Apr 2017 09:20:11 +0800 From: Orson Zhai To: , , , CC: , , Orson Zhai Subject: [PATCH] iio: core: Fix suspicious sizeof usage Date: Tue, 25 Apr 2017 09:16:56 +0800 Message-ID: <1493083016-20571-1-git-send-email-orson.zhai@spreadtrum.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MAIL: SHSQR01.spreadtrum.com v3P1KDjj009788 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pointer size is variours in different system, say 32bit for 4 and 64bit for 8. The 'sizeof(infomask)' may lead to wrong bit numbers. Signed-off-by: Orson Zhai --- drivers/iio/industrialio-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 3ff91e0..795f53c 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1089,7 +1089,7 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev, { int i, ret, attrcount = 0; - for_each_set_bit(i, infomask, sizeof(infomask)*8) { + for_each_set_bit(i, infomask, sizeof(*infomask)*8) { if (i >= ARRAY_SIZE(iio_chan_info_postfix)) return -EINVAL; ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], @@ -1118,7 +1118,7 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev, int i, ret, attrcount = 0; char *avail_postfix; - for_each_set_bit(i, infomask, sizeof(infomask) * 8) { + for_each_set_bit(i, infomask, sizeof(*infomask) * 8) { avail_postfix = kasprintf(GFP_KERNEL, "%s_available", iio_chan_info_postfix[i]);