Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5219423imm; Tue, 18 Sep 2018 06:15:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZXt32PwMAewwJwcDIObAPEuVVAcmUSzO964wmB8OkDbbUAktU+N2JYNY+p0PlFeOH42NZv X-Received: by 2002:a62:3644:: with SMTP id d65-v6mr30597134pfa.133.1537276555820; Tue, 18 Sep 2018 06:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537276555; cv=none; d=google.com; s=arc-20160816; b=OuoHUO1kEyCFwtJeu7TzR1aeA1kpvlLqZALiFoyEKwY+QYF+w7ch7ijnM2V78ukESO s+y4MQzQgdx5LBl04U91OjmxeCKL+1dt+UK34ZznoGc7BK3wETdcg6anuE6FcVqPN/X6 9tarAaLUj7+lrPdfmIfDlotvyEEwZf6YB2LlWhWaQZqs2memF0Ka5CzM1MTPorw8BP7P PhaVR6rJKiWQulaLyBgl0fdILIgUCisBmLooRt2v5VeLlD1TO+RciiuPeZp38lRbNn4b lhyyjZNaVnNvg7XsqIUxWq69H/4WtK2fb8AZAy2BVJMQWuV2MuOPcgHn1q+hZld7R47D q8XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=0bM/UI7yGCdvHi91rNcAHwrOvOM3iatBg2xxawBU1Sw=; b=tDK3Uc7UBnYEYxoXwOEU7N1oM9nSP/i2cQMygn2aKeqiSOKfbGUWL+0lbKE6PuZ2Cb VhWk7MgVuKvjaLeOIR4uDFLm6XESzP6J6Zb6K4zNYl3O38yUEIKpON7EuT/PnDrtzuZ6 l20iUKa98sGqwv9JjnnjZrZDk+M6GZPe/r0CS7dGkyN1RqJZfc1wTXQ2i6AR5uLY9PII yHONg9OMXbuov2bKom5ePRamTQDFSmLrj/Ubem+8Qf+G9LN0vOEHYjUNIgSDOutJsxj6 oadYdfQOYjmFtcckyT0BqVXYNQ449wd0fHL5Mye6XcOIc4hVWfKl+fwmx4eLAVg1VnFX Sigg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v71-v6si17174474pgd.601.2018.09.18.06.15.00; Tue, 18 Sep 2018 06:15:55 -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 S1729646AbeIRSrK (ORCPT + 99 others); Tue, 18 Sep 2018 14:47:10 -0400 Received: from gateway36.websitewelcome.com ([192.185.187.5]:18645 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728718AbeIRSrK (ORCPT ); Tue, 18 Sep 2018 14:47:10 -0400 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 8A6B7400CB714 for ; Tue, 18 Sep 2018 06:58:37 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id 2FVFgdggwPvAd2FVFgXInU; Tue, 18 Sep 2018 07:53:17 -0500 X-Authority-Reason: nr=8 Received: from [189.250.49.176] (port=37470 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1g2FVF-000ba4-8I; Tue, 18 Sep 2018 07:53:17 -0500 Date: Tue, 18 Sep 2018 07:53:14 -0500 From: "Gustavo A. R. Silva" To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] iio: adc: Fix potential integer overflow Message-ID: <20180918125314.GA12752@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.49.176 X-Source-L: No X-Exim-ID: 1g2FVF-000ba4-8I X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.49.176]:37470 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 6 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cast factor to s64 in order to give the compiler complete information about the proper arithmetic to use and avoid a potential integer overflow. Notice that such variable is being used in a context that expects an expression of type s64 (64 bits, signed). Addresses-Coverity-ID: 1324146 ("Unintentional integer overflow") Fixes: e13d757279bb ("iio: adc: Add QCOM SPMI PMIC5 ADC driver") Signed-off-by: Gustavo A. R. Silva --- drivers/iio/adc/qcom-vadc-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index dcd7fb5..e360e27 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -282,7 +282,7 @@ static int qcom_vadc_scale_code_voltage_factor(u16 adc_code, voltage = div64_s64(voltage, data->full_scale_code_volt); if (voltage > 0) { voltage *= prescale->den; - temp = prescale->num * factor; + temp = prescale->num * (s64)factor; voltage = div64_s64(voltage, temp); } else { voltage = 0; -- 2.7.4