]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:29:55 +0000 (10:29 +0200)
commitf57a08ed6d0513ef943486750733c66c416f6203
treea05e701f85443775938c060f3de04356879cc75e
parent661e4e1ba1fc3fe5cce183ff44b7ef565f25b6b2
iio: tsl2583: Fix division by a zero lux_val

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>
drivers/iio/light/tsl2583.c