]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: accel: bma400: Fix uninitialized variable field_value in tap event handling.
authorMikhail Lobanov <m.lobanov@rosalinux.ru>
Tue, 10 Sep 2024 08:36:20 +0000 (04:36 -0400)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 30 Sep 2024 08:20:53 +0000 (09:20 +0100)
In the current implementation, the local variable field_value is used
without prior initialization, which may lead to reading uninitialized
memory. Specifically, in the macro set_mask_bits, the initial
(potentially uninitialized) value of the buffer is copied into old__,
and a mask is applied to calculate new__. A similar issue was resolved in
commit 6ee2a7058fea ("iio: accel: bma400: Fix smatch warning based on use
of unintialized value.").

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 961db2da159d ("iio: accel: bma400: Add support for single and double tap events")
Signed-off-by: Mikhail Lobanov <m.lobanov@rosalinux.ru>
Link: https://patch.msgid.link/20240910083624.27224-1-m.lobanov@rosalinux.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/bma400_core.c

index 89db242f06e0bed46a54f24390073addda63a7ce..441b8df2d0f38dd5b884f58f52a0bfebdb103508 100644 (file)
@@ -1218,7 +1218,8 @@ static int bma400_activity_event_en(struct bma400_data *data,
 static int bma400_tap_event_en(struct bma400_data *data,
                               enum iio_event_direction dir, int state)
 {
-       unsigned int mask, field_value;
+       unsigned int mask;
+       unsigned int field_value = 0;
        int ret;
 
        /*