Resend [PATCH] hidp: Make hidp_get_raw_report abort if the session is terminating
Subsystems (2)
From: Karl Relton <[email protected]>
After linux 3.2 the hid_destroy_device call in hidp_session cleaning up invokes a hook to the power_supply code which in turn tries to read the battery capacity. This read will trigger a call to hidp_get_raw_report which is bound to fail because the device is being taken away - so rather than wait for the 5 second timeout failure this change enables it to fail straight away.
--- net/bluetooth/hidp/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/bluetooth/hidp/core.c +6 -1
@@ -311,6 +311,9 @@ static int hidp_get_raw_report(struct hid_device *hid,int numbered_reports = hid->report_enum[report_type].numbered;int ret; +if (atomic_read (&session->terminate)) +return -EIO ; +switch (report_type) {case HID_FEATURE_REPORT : report_type =HIDP_TRANS_GET_REPORT |HIDP_DATA_RTYPE_FEATURE ;
@@ -695,8 +698,10 @@ static int hidp_session(void *arg)set_current_state (TASK_INTERRUPTIBLE );while (!atomic_read (&session->terminate)) {if (ctrl_sk->sk_state !=BT_CONNECTED || - intr_sk->sk_state !=BT_CONNECTED ) + intr_sk->sk_state !=BT_CONNECTED ) { +atomic_inc (&session->terminate);break ; + }while ((skb =skb_dequeue (&intr_sk->sk_receive_queue))) {skb_orphan (skb);
Signature · 1 line
1.7.9.5
David Herrmann
Reviewed-byHi Karl
One minor nitpick below:
Quoted 29 lines · Karl Relton
From: Karl Relton <[email protected]>
After linux 3.2 the
hid_destroy_devicecall inhidp_sessioncleaning up invokes a hook to thepower_supplycode which in turn tries to read the battery capacity. This read will trigger a call tohidp_get_raw_reportwhich is bound to fail because the device is being taken away - so rather than wait for the 5 second timeout failure this change enables it to fail straight away.Signed-off-by Karl Relton <[email protected]>--- net/bluetooth/hidp/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)net/bluetooth/hidp/core.c +3
-0@@ -311,6 +311,9 @@ static int hidp_get_raw_report(struct hid_device *hid,int numbered_reports = hid->report_enum[report_type].numbered;int ret; +if (atomic_read (&session->terminate)) +return -EIO ; +switch (report_type) {case HID_FEATURE_REPORT : report_type =HIDP_TRANS_GET_REPORT |HIDP_DATA_RTYPE_FEATURE ;
net/bluetooth/hidp/core.c static int hidp_session(void *arg) · line 702
Quoted 6 lines
net/bluetooth/hidp/core.c +2
-1@@ -695,8 +698,10 @@ static int hidp_session(void *arg)set_current_state (TASK_INTERRUPTIBLE );while (!atomic_read (&session->terminate)) {if (ctrl_sk->sk_state !=BT_CONNECTED || - intr_sk->sk_state !=BT_CONNECTED ) + intr_sk->sk_state !=BT_CONNECTED ) { +atomic_inc (&session->terminate);
Lets move this atomic_inc() directly below the while() loop. This guarantees that we won't trap into this again if we add other "break;" conditions.
Other than that the patch looks fine. Feel free to add a:
Thanks
David
Quoted 13 lines
net/bluetooth/hidp/core.c +1
-1break ; + }while ((skb =skb_dequeue (&intr_sk->sk_receive_queue))) {skb_orphan (skb); --1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html