]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
iio: tsl2583: Fix division by a zero lux_val
authorColin Ian King <colin.king@canonical.com>
Fri, 7 May 2021 18:30:41 +0000 (19:30 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 18 Jun 2021 09:07:33 +0000 (11:07 +0200)
commit7c28122dd692049872aa1cb1479738429fe7be14
tree8e5a6555f675fe4d46609b8dd032ae2b12b3e1f9
parenteb58695b29f6ef7e72753933b1a453123595fe1d
iio: tsl2583: Fix division by a zero lux_val

BugLink: https://bugs.launchpad.net/bugs/1931292
commit af0e1871d79cfbb91f732d2c6fa7558e45c31038 upstream.

The lux_val returned from tsl2583_get_lux can potentially be zero,
so check for this to avoid a division by zero and an overflowed
gain_trim_val.

Fixes clang scan-build warning:

drivers/iio/light/tsl2583.c:345:40: warning: Either the
condition 'lux_val<0' is redundant or there is division
by zero at line 345. [zerodivcond]

Fixes: ac4f6eee8fe8 ("staging: iio: TAOS tsl258x: Device driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/iio/light/tsl2583.c