misc: lis3lv02d: Handle click source read errors
Subsystems (2)
PATCH 1/1 misc: lis3lv02d: Handle click source read errors
The threaded click handler ignores the status returned when reading CLICK_SRC. With the SPI transport, spi_w8r8() can fail without storing anything in the output byte. The handler then tests an uninitialized click_src and can report spurious axis button events.
Check the read status and skip the event when CLICK_SRC cannot be fetched. Exit through the common unlock path so successful event handling and mutex coverage remain unchanged.
This issue was found by a static analysis checker and confirmed by manual source review.
Fixes 6d94d4081048 ("lis3: interrupt handlers for 8bit wakeup and click events")
Signed-off-by Ruoyu Wang <[email protected]>
--- drivers/misc/lis3lv02d/lis3lv02d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/lis3lv02d/lis3lv02d.c +3 -1
@@ -511,7 +511,8 @@ static void lis302dl_interrupt_handle_click(struct lis3lv02d *lis3)u8 click_src;mutex_lock (&lis3->mutex); - lis3->read (lis3,CLICK_SRC , &click_src); +if (lis3->read (lis3,CLICK_SRC , &click_src) <0 ) + goto out;if (click_src &CLICK_SINGLE_X ) {input_report_key (dev, lis3->mapped_btns[0 ],1 );
@@ -528,6 +529,7 @@ static void lis302dl_interrupt_handle_click(struct lis3lv02d *lis3)input_report_key (dev, lis3->mapped_btns[2 ],0 ); }input_sync (dev); +out:mutex_unlock (&lis3->mutex); }
Signature · 1 line
2.51.0