Skip to content

Commit 6f20d32

Browse files
Nikita ZhandarovichBenjamin Tissoires
authored andcommitted
HID: logitech-dj: Fix error handling in logi_dj_recv_switch_to_dj_mode()
Presently, if a call to logi_dj_recv_send_report() fails, we do not learn about the error until after sending short HID_OUTPUT_REPORT with hid_hw_raw_request(). To handle this somewhat unlikely issue, return on error in logi_dj_recv_send_report() (minding ugly sleep workaround) and take into account the result of hid_hw_raw_request(). Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 6a9ddc8 ("HID: logitech-dj: enable notifications on connect/disconnect") Signed-off-by: Nikita Zhandarovich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent ed1fb63 commit 6f20d32

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/hid/hid-logitech-dj.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,9 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
12851285
* 50 msec should gives enough time to the receiver to be ready.
12861286
*/
12871287
msleep(50);
1288+
1289+
if (retval)
1290+
return retval;
12881291
}
12891292

12901293
/*
@@ -1306,7 +1309,7 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
13061309
buf[5] = 0x09;
13071310
buf[6] = 0x00;
13081311

1309-
hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf,
1312+
retval = hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf,
13101313
HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT,
13111314
HID_REQ_SET_REPORT);
13121315

0 commit comments

Comments
 (0)