diff mbox

[1/2] HID: sensors: use GFP_ATOMIC under spinlock

Message ID 20120914065323.GD11886@elgon.mountain (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Dan Carpenter Sept. 14, 2012, 6:53 a.m. UTC
We're holding a spinlock here so we can't call kmalloc() with
GFP_KERNEL.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jiri Kosina Sept. 17, 2012, 10:59 a.m. UTC | #1
On Fri, 14 Sep 2012, Dan Carpenter wrote:

> We're holding a spinlock here so we can't call kmalloc() with
> GFP_KERNEL.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Jonathan, could you please take this one as well, as it depends on the 
series in your tree?

Thanks.

> 
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 4ac759c..0c93b10 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -173,7 +173,7 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
>  			spin_unlock(&pdata->dyn_callback_lock);
>  			return -EINVAL;
>  		}
> -	callback = kzalloc(sizeof(*callback), GFP_KERNEL);
> +	callback = kzalloc(sizeof(*callback), GFP_ATOMIC);
>  	if (!callback) {
>  		spin_unlock(&pdata->dyn_callback_lock);
>  		return -ENOMEM;
> @@ -462,7 +462,7 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
>  		if (pdata->pending.status && pdata->pending.attr_usage_id ==
>  				report->field[i]->usage->hid) {
>  			hid_dbg(hdev, "data was pending ...\n");
> -			pdata->pending.raw_data = kmalloc(sz, GFP_KERNEL);
> +			pdata->pending.raw_data = kmalloc(sz, GFP_ATOMIC);
>  			if (pdata->pending.raw_data) {
>  				memcpy(pdata->pending.raw_data, ptr, sz);
>  				pdata->pending.raw_size  = sz;
>
Pandruvada, Srinivas Sept. 17, 2012, 3:21 p.m. UTC | #2
Tested this and works. 

-----Original Message-----
From: Jiri Kosina [mailto:jkosina@suse.cz] 
Sent: Monday, September 17, 2012 3:59 AM
To: Dan Carpenter
Cc: Pandruvada, Srinivas; linux-input@vger.kernel.org; kernel-janitors@vger.kernel.org; Jonathan Cameron
Subject: Re: [patch 1/2] HID: sensors: use GFP_ATOMIC under spinlock

On Fri, 14 Sep 2012, Dan Carpenter wrote:

> We're holding a spinlock here so we can't call kmalloc() with 
> GFP_KERNEL.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Jonathan, could you please take this one as well, as it depends on the series in your tree?

Thanks.

> 
> diff --git a/drivers/hid/hid-sensor-hub.c 
> b/drivers/hid/hid-sensor-hub.c index 4ac759c..0c93b10 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -173,7 +173,7 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
>  			spin_unlock(&pdata->dyn_callback_lock);
>  			return -EINVAL;
>  		}
> -	callback = kzalloc(sizeof(*callback), GFP_KERNEL);
> +	callback = kzalloc(sizeof(*callback), GFP_ATOMIC);
>  	if (!callback) {
>  		spin_unlock(&pdata->dyn_callback_lock);
>  		return -ENOMEM;
> @@ -462,7 +462,7 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
>  		if (pdata->pending.status && pdata->pending.attr_usage_id ==
>  				report->field[i]->usage->hid) {
>  			hid_dbg(hdev, "data was pending ...\n");
> -			pdata->pending.raw_data = kmalloc(sz, GFP_KERNEL);
> +			pdata->pending.raw_data = kmalloc(sz, GFP_ATOMIC);
>  			if (pdata->pending.raw_data) {
>  				memcpy(pdata->pending.raw_data, ptr, sz);
>  				pdata->pending.raw_size  = sz;
> 

--
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 4ac759c..0c93b10 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -173,7 +173,7 @@  int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
 			spin_unlock(&pdata->dyn_callback_lock);
 			return -EINVAL;
 		}
-	callback = kzalloc(sizeof(*callback), GFP_KERNEL);
+	callback = kzalloc(sizeof(*callback), GFP_ATOMIC);
 	if (!callback) {
 		spin_unlock(&pdata->dyn_callback_lock);
 		return -ENOMEM;
@@ -462,7 +462,7 @@  static int sensor_hub_raw_event(struct hid_device *hdev,
 		if (pdata->pending.status && pdata->pending.attr_usage_id ==
 				report->field[i]->usage->hid) {
 			hid_dbg(hdev, "data was pending ...\n");
-			pdata->pending.raw_data = kmalloc(sz, GFP_KERNEL);
+			pdata->pending.raw_data = kmalloc(sz, GFP_ATOMIC);
 			if (pdata->pending.raw_data) {
 				memcpy(pdata->pending.raw_data, ptr, sz);
 				pdata->pending.raw_size  = sz;