diff mbox

[RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL

Message ID 1347764305.3748.1.camel@phoenix (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

axel lin Sept. 16, 2012, 2:58 a.m. UTC
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 mbox

Patch

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);