Skip to contentSkip to conversation

HID: sensors: use GFP_ATOMIC under spinlock

PATCH In review Dan Carpenter 3 participants 3 messages Sep 14, 2012 – Sep 17, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 HID: sensors: use GFP_ATOMIC under spinlock

We're holding a spinlock here so we can't call kmalloc() with GFP_KERNEL.

drivers/hid/hid-sensor-hub.c +2 -2
index 4ac759c..0c93b10 100644
@@ -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;
#1 lore raw
Quoted 4 lines · Dan Carpenter

We're holding a spinlock here so we can't call kmalloc() with GFP_KERNEL.

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

Thanks.

Quoted 24 lines
drivers/hid/hid-sensor-hub.c +2 -2
index 4ac759c..0c93b10 100644
@@ -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;
Signature · 2 lines
Jiri Kosina
SUSE Labs
#2 lore raw

Tested this and works.

-----Original Message-----
From: Jiri Kosina [mailto:[email protected]]
Sent: Monday, September 17, 2012 3:59 AM
To: Dan Carpenter
Cc: Pandruvada, Srinivas; [email protected]; [email protected]; Jonathan Cameron
Subject: Re: [patch 1/2] HID: sensors: use GFP_ATOMIC under spinlock

Quoted 4 lines · Dan Carpenter

We're holding a spinlock here so we can't call kmalloc() with GFP_KERNEL.

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

Thanks.

Quoted 16 lines
(quoted diff) +0 -0

b/drivers/hid/hid-sensor-hub.c index 4ac759c..0c93b10 100644

drivers/hid/hid-sensor-hub.c +1 -1
@@ -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;

drivers/hid/hid-sensor-hub.c static int sensor_hub_raw_event(struct hid_device *hdev, · line 468

Quoted 8 lines
drivers/hid/hid-sensor-hub.c +1 -1
@@ -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