Bluetooth: hidp: Fix error checks in hidp_get/set_raw_report
Subsystems (5)
PATCH 1/1 Bluetooth: hidp: Fix error checks in hidp_get/set_raw_report
Commit 48d9cc9d85dd ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes") changed hidp_send_message 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 (all?) drivers, such as hid-sony for the Dualshock 4 in Bluetooth mode.
--- net/bluetooth/hidp/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/hidp/core.c +2 -2
@@ -267,7 +267,7 @@ static int hidp_get_raw_report(struct hid_device *hid,set_bit (HIDP_WAITING_FOR_RETURN , &session->flags); data[0 ] = report_number; ret =hidp_send_ctrl_message (session, report_type, data,1 ); -if (ret) +if (ret <0 ) goto err;/* 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, data[0 ] = reportnum;set_bit (HIDP_WAITING_FOR_SEND_ACK , &session->flags); ret =hidp_send_ctrl_message (session, report_type, data, count); -if (ret) +if (ret <0 ) goto err;/* Wait for the ACK from the device. */
Signature · 1 line
2.23.0
Quoted 7 lines · Dan Elkouby
Commit
48d9cc9d85dd("Bluetooth: hidp: Lethidp_send_messagereturn number of queued bytes") changedhidp_send_messageto 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 (all?) drivers, such as hid-sony for the Dualshock 4 in Bluetooth mode.Signed-off-by Dan Elkouby <[email protected]>
I think we also need to update update ms_ff_worker() which assumes that hid_hw_output_report() returns zero on success. Please use the Fixes tag for this since a lot of scripts rely on it to decide what to backport.
Otherwise, it looks good. Thanks for catching this.
regards,
dan carpenter
Quoted 2 lines · Dan Carpenter
I think we also need to update update
ms_ff_worker()which assumes thathid_hw_output_report()returns zero on success.
Yes, it looks like that's the case. Should I amend my patch to include this fix, or should it be a separate patch? I don't have access to any hardware covered by hid-microsoft, so I won't be able to test it.
Quoted 5 lines
Please use the Fixes
tag for this since a lot of scripts rely on it to decide what to backport.Fixes 48d9cc9d85dd ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes")
Will do.
Quoted 1 line
Otherwise, it looks good. Thanks for catching this.
Thanks for taking a look!
(Sorry for sending this twice, I'm not used to mailing lists and forgot to reply to all.)
Quoted 8 lines · Dan Elkouby
Quoted 2 lines · Dan Carpenter
I think we also need to update update
ms_ff_worker()which assumes thathid_hw_output_report()returns zero on success.Yes, it looks like that's the case. Should I amend my patch to include this fix, or should it be a separate patch? I don't have access to any hardware covered by hid-microsoft, so I won't be able to test it.
Yes. Please amend the patch. We all understand that you don't have the hardware so it's not a problem. If you want to blame me in the commit message that's fine. "Dan Carpenter pointed out a related issue in ms_ff_worker()". But we're only silencing a warning so it can't really break anything.
You can add my Reviewed-by tag as well when you resend.
regards,
dan carpenter
PATCH 1/1 Bluetooth: hidp: Fix assumptions on the return value of hidp_send_message
In reply to Dan Carpenterhidp_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.
--- drivers/hid/hid-microsoft.c | 2 +- net/bluetooth/hidp/core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/hid/hid-microsoft.c +1 -1
@@ -303,7 +303,7 @@ static void ms_ff_worker(struct work_struct *work) r->magnitude[MAGNITUDE_WEAK ] = ms->weak;/* right actuator */ ret =hid_hw_output_report (hdev, (__u8 *)r,sizeof (*r)); -if (ret) +if (ret <0 )hid_warn (hdev,"failed to send FF report\n" ); }
net/bluetooth/hidp/core.c +2 -2
@@ -267,7 +267,7 @@ static int hidp_get_raw_report(struct hid_device *hid,set_bit (HIDP_WAITING_FOR_RETURN , &session->flags); data[0 ] = report_number; ret =hidp_send_ctrl_message (session, report_type, data,1 ); -if (ret) +if (ret <0 ) goto err;/* 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, data[0 ] = reportnum;set_bit (HIDP_WAITING_FOR_SEND_ACK , &session->flags); ret =hidp_send_ctrl_message (session, report_type, data, count); -if (ret) +if (ret <0 ) goto err;/* Wait for the ACK from the device. */
Signature · 1 line
2.23.0
Re: [PATCH] Bluetooth: hidp: Fix assumptions on the return value of hidp_send_message
Quoted 11 lines · Dan Elkouby
hidp_send_messagewas 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 48d9cc9d85dd ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes")Signed-off-by Dan Elkouby <[email protected]>
Thanks!
regards,
dan carpenter
Re: [PATCH] Bluetooth: hidp: Fix assumptions on the return value of hidp_send_message
In reply to Dan ElkoubyQuoted 11 lines · Dan Elkouby
hidp_send_messagewas 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 48d9cc9d85dd ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes")Signed-off-by Dan Elkouby <[email protected]>
Marcel, are you taking this through your tree?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Marcel Holtmann
maintainerRe: [PATCH] Bluetooth: hidp: Fix assumptions on the return value of hidp_send_message
Hi Jiri,
Quoted 8 lines
Quoted 8 lines
hidp_send_messagewas 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.
Quoted 7 lines
Quoted 3 lines
Fixes 48d9cc9d85dd ("Bluetooth: hidp: Let hidp_send_message return number of queued bytes")Signed-off-by Dan Elkouby <[email protected]>Reviewed-by Jiri Kosina <[email protected]>Marcel, are you taking this through your tree?
I am taking this through my tree. And yes, I applied the updated patch, but answered the other ;)
Regards
Marcel
Re: [PATCH] Bluetooth: hidp: Fix assumptions on the return value of hidp_send_message
Quoted 5 lines
I am taking this through my tree. And yes, I applied the updated patch, but answered the other ;)
Regards
Marcel
Are you also going to mark this patch for inclusion to stable tree? I haven't seen it in any of the stable queues (netdev, Greg's), so just wanted to check.
Thanks,
Andrey Smirnov
Marcel Holtmann
maintainerHi Dan,
Quoted 10 lines
Commit
48d9cc9d85dd("Bluetooth: hidp: Lethidp_send_messagereturn number of queued bytes") changedhidp_send_messageto 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 (all?) drivers, such as hid-sony for the Dualshock 4 in Bluetooth mode.Signed-off-by Dan Elkouby <[email protected]>---
net/bluetooth/hidp/core.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Quoted 2 lines · Marcel Holtmann
patch has been applied to bluetooth-next tree.
Thanks a lot!
Quoted 8 lines · Marcel Holtmann
Hi Dan,
Quoted 6 lines
Commit
48d9cc9d85dd("Bluetooth: hidp: Lethidp_send_messagereturn number of queued bytes") changedhidp_send_messageto 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 (all?) drivers, such as hid-sony for the Dualshock 4 in Bluetooth mode.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Dan Elkouby <[email protected]>---
net/bluetooth/hidp/core.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)patch has been applied to bluetooth-next tree.
The v2 added an additional fix and used the Fixes tag. Could you apply that instead?
regards,
dan carpenter
Marcel Holtmann
maintainerHi Dan,
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Commit
48d9cc9d85dd("Bluetooth: hidp: Lethidp_send_messagereturn number of queued bytes") changedhidp_send_messageto 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 (all?) drivers, such as hid-sony for the Dualshock 4 in Bluetooth mode.Signed-off-by Dan Elkouby <[email protected]>---
net/bluetooth/hidp/core.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines
patch has been applied to bluetooth-next tree.
The v2 added an additional fix and used the Fixes tag. Could you apply that instead?
see my reply to Jiri. I replied to the wrong patch, but actually applied to the updated one.
Regards
Marcel