All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: srinivas pandruvada <srinivas.pandruvada@intel.com>,
	Jonathan Cameron <jic23@kernel.org>,
	linux-input@vger.kernel.org
Subject: [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL
Date: Sun, 16 Sep 2012 10:58:25 +0800	[thread overview]
Message-ID: <1347764305.3748.1.camel@phoenix> (raw)

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




             reply	other threads:[~2012-09-16  2:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-16  2:58 Axel Lin [this message]
2012-09-16  3:30 ` [PATCH RFT] HID: sensor-hub: don't hold spin lock while calling kzalloc with GFP_KERNEL Pandruvada, Srinivas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347764305.3748.1.camel@phoenix \
    --to=axel.lin@gmail.com \
    --cc=jic23@kernel.org \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=srinivas.pandruvada@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.