linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL
@ 2012-09-16  2:58 Axel Lin
  2012-09-16  3:30 ` Pandruvada, Srinivas
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-09-16  2:58 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: srinivas pandruvada, Jonathan Cameron, linux-input

kzalloc might cause sleep, so don't hold spin lock while calling kzalloc with
GFP_KERNEL.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/hid/hid-sensor-hub.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 4ac759c..162bf6a 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -173,14 +173,17 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
 			spin_unlock(&pdata->dyn_callback_lock);
 			return -EINVAL;
 		}
+	spin_unlock(&pdata->dyn_callback_lock);
+
 	callback = kzalloc(sizeof(*callback), GFP_KERNEL);
-	if (!callback) {
-		spin_unlock(&pdata->dyn_callback_lock);
+	if (!callback)
 		return -ENOMEM;
-	}
+
 	callback->usage_callback = usage_callback;
 	callback->usage_id = usage_id;
 	callback->priv = NULL;
+
+	spin_lock(&pdata->dyn_callback_lock);
 	list_add_tail(&callback->list, &pdata->dyn_callback_list);
 	spin_unlock(&pdata->dyn_callback_lock);
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL
  2012-09-16  2:58 [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL Axel Lin
@ 2012-09-16  3:30 ` Pandruvada, Srinivas
  0 siblings, 0 replies; 2+ messages in thread
From: Pandruvada, Srinivas @ 2012-09-16  3:30 UTC (permalink / raw)
  To: Axel Lin, Jiri Kosina; +Cc: Jonathan Cameron, linux-input@vger.kernel.org

There is already a patch submitted to change to GFP_ATOMIC, which address this.

-----Original Message-----
From: Axel Lin [mailto:axel.lin@gmail.com] 
Sent: Saturday, September 15, 2012 7:58 PM
To: Jiri Kosina
Cc: Pandruvada, Srinivas; Jonathan Cameron; linux-input@vger.kernel.org
Subject: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL

kzalloc might cause sleep, so don't hold spin lock while calling kzalloc with GFP_KERNEL.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/hid/hid-sensor-hub.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 4ac759c..162bf6a 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -173,14 +173,17 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
 			spin_unlock(&pdata->dyn_callback_lock);
 			return -EINVAL;
 		}
+	spin_unlock(&pdata->dyn_callback_lock);
+
 	callback = kzalloc(sizeof(*callback), GFP_KERNEL);
-	if (!callback) {
-		spin_unlock(&pdata->dyn_callback_lock);
+	if (!callback)
 		return -ENOMEM;
-	}
+
 	callback->usage_callback = usage_callback;
 	callback->usage_id = usage_id;
 	callback->priv = NULL;
+
+	spin_lock(&pdata->dyn_callback_lock);
 	list_add_tail(&callback->list, &pdata->dyn_callback_list);
 	spin_unlock(&pdata->dyn_callback_lock);
 
--
1.7.9.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-16  3:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-16  2:58 [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL Axel Lin
2012-09-16  3:30 ` Pandruvada, Srinivas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).