Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3706731pxa; Sun, 9 Aug 2020 09:01:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdQRIYt9nngLnOuz0yNK0g954L1O+VedTrpNcEqndyJ7la013z0k6ou8IdNuMiCq9Fy9f4 X-Received: by 2002:a17:906:46cc:: with SMTP id k12mr18073093ejs.366.1596988861230; Sun, 09 Aug 2020 09:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596988861; cv=none; d=google.com; s=arc-20160816; b=TaRwSE4he15F5ygNkVJeU5UKGYOiQoCK5HkYJuYRivP7WSnCizL4t7Y4DJOQtLJYHR X/W8qGr6iRC7KcJFnXeUWHAHnra7CsIAkl+99SgGbJExBiYF/p1NRzbuq8oRv2BEuzzN u4OmgPWyw/YI1qF2d8WmZa6qS6jmQBrnGAJsksYM1oQ40Gw91Z4qawR6hVinp20tp3Uz lDS2le0sJszlbPf++IAhZnf4ABKj12+AygsOHfs1VchG7KDX7L/4i9xMnnhQkp5KlePK 8g0ThsEiW3DnZ1Nl4EMTwFA3GyIMpGk3x+Ew45u9nvR6ZGIh9JWRckgnAOKYZBQWSkJU 9nCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=xG+8uieNrMAP0UGTh1w832zRGIBKTtCxlShJe5RBqBY=; b=hMsb020+31fHBeqiWeF8kCubAS2skA/VWZ/iZI/GFTQrFR3+nRz4ifnkHiEYpr/DuY +WxdbSRNUrIbBYqlVuIlNEiiJHDDlGDn2Q5weOeGgKlf2D5MpbXi3OHYqm3TJbZLdbxe mdIJWA6yuNff6fcXKyTFkZztaG9kKyYVPdwsdgQQGR/SgBXmgIHfgVzo4M7m+4w5CjM/ JDs8HK6zIheGJjLEn07TmgAk7l8Q3DnsHk28xJoczByGyttjZ8J0Xh8oqG7qF0np8qll FFpcLhGN7Pg0MLhec40pq5emtY0YKX8+fptx1XgfQ22OgFHosjQpZkYDv3LklAiFmA6M p4Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dxBNrcTa; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si5453432ejd.365.2020.08.09.09.00.37; Sun, 09 Aug 2020 09:01:01 -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=@redhat.com header.s=mimecast20190719 header.b=dxBNrcTa; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726256AbgHIP7u (ORCPT + 99 others); Sun, 9 Aug 2020 11:59:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51174 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726200AbgHIP7s (ORCPT ); Sun, 9 Aug 2020 11:59:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596988784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=xG+8uieNrMAP0UGTh1w832zRGIBKTtCxlShJe5RBqBY=; b=dxBNrcTa6ohjcTdxtSU3u/KqS2oh4TwuGdGJ4BaHXyBNURZQ9XBny0isOVWIIRNGc1jTqW C+hB+dBip1+mXlW326TKj9GKlQwT1phAo+o7k8vUeDzze85ely+8hAR//INedhLTQWPSM8 vNDDS8Andd1gsdEtKnYnkrDsoW5kl+0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-386-9QuKDFC6NAqav10xHGktiw-1; Sun, 09 Aug 2020 11:59:42 -0400 X-MC-Unique: 9QuKDFC6NAqav10xHGktiw-1 Received: by mail-qk1-f200.google.com with SMTP id 195so5425506qke.14 for ; Sun, 09 Aug 2020 08:59:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xG+8uieNrMAP0UGTh1w832zRGIBKTtCxlShJe5RBqBY=; b=rtZOSgo8a8ewxGWeKZyNND3VjRvqSnk+ANsNM548KnDuKGcFoHCcz3jUu+o7yBM0Lz aVM3JnnrJalU0xiZxynK7lulsvH62lbXTWfOZ2fb7hYCG5riMHesr4wm7BloCK/FCW2I yko3XlvwcG+4HH/2rDhhEsMHjTJmPAAS53EI9wIIIaL1cTZFWcpQS5WphzZC8xiDZBOS xcw0E/ap3z2txYV8DarVDGRhYVgE1xtssZ5q9Lo0BYOL43WkFvDeeePA3giZWehzQ7YX 2XKM3PHZDRky2X5TLgJiBzAEB/A1tAtFwLeQvuQeiTcbAKDGFkBEL8hVvquWOXRYPG7i eBdA== X-Gm-Message-State: AOAM533yOWS5lf6Y9gYlWZpJKbxE5xyAFZa3P0+g1RsgiIGtLZ1NfQuc WGg07yH7k6baDWrAEeGUAY2ij0izzfkn4Z/zrBYOZbT0zxJ1xzGAL3Hvo7t7RVLWuf8T3JYKLzx kINnwo9YmCVu4E5FOvUqwedh7 X-Received: by 2002:a05:620a:676:: with SMTP id a22mr22806364qkh.8.1596988782402; Sun, 09 Aug 2020 08:59:42 -0700 (PDT) X-Received: by 2002:a05:620a:676:: with SMTP id a22mr22806349qkh.8.1596988782146; Sun, 09 Aug 2020 08:59:42 -0700 (PDT) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id k48sm14978268qtk.44.2020.08.09.08.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 08:59:41 -0700 (PDT) From: trix@redhat.com To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, jmaneyrol@invensense.com, mirq-linux@rere.qmqm.pl, lee.jones@linaro.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rix Subject: [PATCH] iio: imu: inv_mpu6050: check for temp_fifo_enable Date: Sun, 9 Aug 2020 08:59:36 -0700 Message-Id: <20200809155936.16898-1-trix@redhat.com> X-Mailer: git-send-email 2.18.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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