Skip to content

Commit 8bb3537

Browse files
9aryholtmann
authored andcommitted
Bluetooth: hidp: Fix assumptions on the return value of hidp_send_message
hidp_send_message was changed to return non-zero values on success, which some other bits did not expect. This caused spurious errors to be propagated through the stack, breaking some drivers, such as hid-sony for the Dualshock 4 in Bluetooth mode. As pointed out by Dan Carpenter, hid-microsoft directly relied on that assumption as well. Fixes: 48d9cc9 ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes") Signed-off-by: Dan Elkouby <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Reviewed-by: Jiri Kosina <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent d7ef0d1 commit 8bb3537

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/hid/hid-microsoft.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static void ms_ff_worker(struct work_struct *work)
303303
r->magnitude[MAGNITUDE_WEAK] = ms->weak; /* right actuator */
304304

305305
ret = hid_hw_output_report(hdev, (__u8 *)r, sizeof(*r));
306-
if (ret)
306+
if (ret < 0)
307307
hid_warn(hdev, "failed to send FF report\n");
308308
}
309309

net/bluetooth/hidp/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int hidp_get_raw_report(struct hid_device *hid,
267267
set_bit(HIDP_WAITING_FOR_RETURN, &session->flags);
268268
data[0] = report_number;
269269
ret = hidp_send_ctrl_message(session, report_type, data, 1);
270-
if (ret)
270+
if (ret < 0)
271271
goto err;
272272

273273
/* Wait for the return of the report. The returned report
@@ -343,7 +343,7 @@ static int hidp_set_raw_report(struct hid_device *hid, unsigned char reportnum,
343343
data[0] = reportnum;
344344
set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags);
345345
ret = hidp_send_ctrl_message(session, report_type, data, count);
346-
if (ret)
346+
if (ret < 0)
347347
goto err;
348348

349349
/* Wait for the ACK from the device. */

0 commit comments

Comments
 (0)