Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4127425pxa; Mon, 10 Aug 2020 01:06:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/644epQXqJsUB40ira+Jlx8tLMpSGZcd9RwOQGH7hfSCwFKXTiG/CdRGhN6qsOSghPdhc X-Received: by 2002:a17:906:2e0c:: with SMTP id n12mr20179276eji.35.1597046781219; Mon, 10 Aug 2020 01:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597046781; cv=none; d=google.com; s=arc-20160816; b=oxZnnS9HKVzIXHFK3DWhHhefSjD6HHCxHGF34MTXQYj3+wudegET5Jq3902TRr8HoI RB1UtOiq/xVZ+8Brisd0z4OJtXcP0XZBmF38TlhUagSpGS8C/ZlBepHwZTGKbWVOxm/m JrlLQkedoNV26ouA+5Xx+DMEKzkOgVkTYpOIbsD0RNq1k/6s6jQ3LKI84XPZDqcp3wdN oiF6245YHGM8u0baZ3Vu/xmiXhtfvyCWaHnt9h1pOfWvyOA2WmQTe3kT4fQKscRbspzZ hz3Nuhc+OOB0LpUp2pkve1Vhyje4NmRba9tUVjckYM9Xv3xMPe6UTnIl6IhTvSI7IZz7 Kh2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EIVYbfl60/LCAXTYgKZTMLflQoCrjmA+x5UQf4DHC8U=; b=YJSlcdWDeOSRHZI5gUjTySH2tZU6R2fY6Xq9vtXhsB59HHc6AA+NZlg7u1bHkj+2Az aWPnm5dsYUKdFTUf4ADhGtfV4lrC62PneU1/0ZXuEbSVdf3/mFlbi2jsza6DfA1Huscf nHgmekvcrViMCEQ9tuhGy7c04Vi968z3HFt8kO0tTtlkOyHrtOb7FiytU60APix3w4XV Cn87XwfvGtdA4RkNKuTgRYE15Du3ZRXl8hZNjuBvkgZrs85CF7AZdbUgUZox+4e7+61A nB06DWSGe2FPkq18VU3asl8vvJ/DYfqBFTpqxgNCzicgR4dXTDnUyTJ3fk6VMrHYk7If 4E7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BLFDPlRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si9838748edi.143.2020.08.10.01.05.58; Mon, 10 Aug 2020 01:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BLFDPlRa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726489AbgHJIDD (ORCPT + 99 others); Mon, 10 Aug 2020 04:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbgHJIDC (ORCPT ); Mon, 10 Aug 2020 04:03:02 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC83C061756; Mon, 10 Aug 2020 01:03:02 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id f10so4356801plj.8; Mon, 10 Aug 2020 01:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EIVYbfl60/LCAXTYgKZTMLflQoCrjmA+x5UQf4DHC8U=; b=BLFDPlRaEIp2bEVswqI1V3rY6FhRvyvhrKzRCgp8XtqofWcIO+R2xg8xsxH+g2ewCL rKZodlVz6vEJ7jlUQlvTofVSMkNZbEA2ofzmZ3Ll51KfOTeZiFe05PYW7MLdHw6hegtL rxNbcrLM8whucUuOnBpyL91evVA3dVoD9m2ZX2Up7xDYXIxhnUaip/iP3x8LFfm9+he/ LSEPg3VY2l/QFnbByOpMMZoPEPResMdy6KsbmIVNE2HHBDDMBLllUuZnvn4c5AQjGgY4 9Om+TeqtZnUgAeaRCIX3vxbJR8Jbq45fYYcREg5j3DGJ0cSHEUJGr+YdBHyMl5AIBY5E nEaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EIVYbfl60/LCAXTYgKZTMLflQoCrjmA+x5UQf4DHC8U=; b=tvES0O1BfZT5pDr/3/k2ynTMYbwwnl9k02PRazNFak+OMGxpHzwB7z7P8N5TLGIpZ1 Rm5TDDo6swmd2XpCJohFFLTGXX/c6V5K+aBZhh3oZ3w1y7iWdozyhrI84/StGwBkwojq VNeFhCbdKy8Fw6aOJaJzWFbFUybLvD71oJjNtudMZVII3czkHBoUuGcPEnHpSlYAWGCa fwyvVd9NxpnBWDbzgMSk9ELANqVdZdONnBwBioPvVhor9FZBdm9JahFRFSfZxJTih/4P OD/1dIbDRe9984Klv9x2gEN2wLk4aKjQvy+O21ywm2Hw8LoxH1JCW+5NFPZF3+Ge6zto 0qow== X-Gm-Message-State: AOAM531yfB1xKFn013vqTQZWY+K3YJHqepLSHgdz283097+CVJgmsJp5 7Ry1sP66KxRap74jI6mwcQdF6WfEz+be2viIcWTi97f4kdLi5A== X-Received: by 2002:a17:902:8491:: with SMTP id c17mr22749650plo.262.1597046581567; Mon, 10 Aug 2020 01:03:01 -0700 (PDT) MIME-Version: 1.0 References: <20200809155936.16898-1-trix@redhat.com> In-Reply-To: <20200809155936.16898-1-trix@redhat.com> From: Andy Shevchenko Date: Mon, 10 Aug 2020 11:02:45 +0300 Message-ID: Subject: Re: [PATCH] iio: imu: inv_mpu6050: check for temp_fifo_enable To: trix@redhat.com Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Jean-Baptiste Maneyrol , =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Lee Jones , linux-iio , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 9, 2020 at 7:00 PM wrote: > > From: Tom Rix > > clang static analysis reports this problem > > inv_mpu_ring.c:181:18: warning: Division by zero > nb = fifo_count / bytes_per_datum; > ~~~~~~~~~~~^~~~~~~~~~~~~~~~~ > > This is a false positive. > Dividing by 0 is protected by this check > > if (!(st->chip_config.accl_fifo_enable | > st->chip_config.gyro_fifo_enable | > st->chip_config.magn_fifo_enable)) > goto end_session; > bytes_per_datum = 0; > > But there is another fifo, temp_fifo > > if (st->chip_config.temp_fifo_enable) > bytes_per_datum += INV_MPU6050_BYTES_PER_TEMP_SENSOR; > > Which would be skipped if it was the only enabled fifo. > So add to the check. > > Fixes: 2e4c0a5e2576 ("iio: imu: inv_mpu6050: add fifo temperature data support") > > Signed-off-by: Tom Rix There shouldn't be a blank line in between. Other than that, Reviewed-by: Andy Shevchenko > --- > drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c > index b533fa2dad0a..5240a400dcb4 100644 > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c > @@ -141,6 +141,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) > > if (!(st->chip_config.accl_fifo_enable | > st->chip_config.gyro_fifo_enable | > + st->chip_config.temp_fifo_enable | > st->chip_config.magn_fifo_enable)) > goto end_session; > bytes_per_datum = 0; > -- > 2.18.1 > -- With Best Regards, Andy Shevchenko