[PATCH] HID: intel-ish-hid: Fix potential race condition

Subsystems: hid core layer, intel integrated sensor hub driver, the rest

STALE3537d

2 messages, 2 authors, 2016-11-29 · open the first message on its own page

[PATCH] HID: intel-ish-hid: Fix potential race condition

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date: 2016-11-28 19:23:39

Although unlikely but it is possible that when a connect or disconnect
request is issued to the firmware, before the response comes, user
terminates the client session. In this case when the response is arrived
there is no matching client instance in the list of currently active
clients. In this case, don't issue call to wake up a waiting client.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---

This issue is not reported. This was found during code reviews for fault
tolerance.
So not a fix for 4.9.rc release.


 drivers/hid/intel-ish-hid/ishtp/hbm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/intel-ish-hid/ishtp/hbm.c b/drivers/hid/intel-ish-hid/ishtp/hbm.c
index 74bffee..59460b6 100644
--- a/drivers/hid/intel-ish-hid/ishtp/hbm.c
+++ b/drivers/hid/intel-ish-hid/ishtp/hbm.c
@@ -378,11 +378,10 @@ static void ishtp_hbm_cl_disconnect_res(struct ishtp_device *dev,
 	list_for_each_entry(cl, &dev->cl_list, link) {
 		if (!rs->status && ishtp_hbm_cl_addr_equal(cl, rs)) {
 			cl->state = ISHTP_CL_DISCONNECTED;
+			wake_up_interruptible(&cl->wait_ctrl_res);
 			break;
 		}
 	}
-	if (cl)
-		wake_up_interruptible(&cl->wait_ctrl_res);
 	spin_unlock_irqrestore(&dev->cl_list_lock, flags);
 }
 
@@ -431,11 +430,10 @@ static void ishtp_hbm_cl_connect_res(struct ishtp_device *dev,
 				cl->state = ISHTP_CL_DISCONNECTED;
 				cl->status = -ENODEV;
 			}
+			wake_up_interruptible(&cl->wait_ctrl_res);
 			break;
 		}
 	}
-	if (cl)
-		wake_up_interruptible(&cl->wait_ctrl_res);
 	spin_unlock_irqrestore(&dev->cl_list_lock, flags);
 }
 
-- 
2.7.4

Re: [PATCH] HID: intel-ish-hid: Fix potential race condition

From: Jiri Kosina <jikos@kernel.org>
Date: 2016-11-29 14:28:20

On Mon, 28 Nov 2016, Srinivas Pandruvada wrote:
Although unlikely but it is possible that when a connect or disconnect
request is issued to the firmware, before the response comes, user
terminates the client session. In this case when the response is arrived
there is no matching client instance in the list of currently active
clients. In this case, don't issue call to wake up a waiting client.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---

This issue is not reported. This was found during code reviews for fault
tolerance.
So not a fix for 4.9.rc release.
Applied to for-4.10/intel-ish.

-- 
Jiri Kosina
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help