[PATCH] usbhid: use GFP_NOIO in reset code path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For mice with card readers the HID driver can deadlock
as its post_reset() method allocates memory. GFP_NOIO
must be used in a block layer error handler, which
usbhid can be indirectly part of.

Signed-off-by: Oliver Neukum <oneukum@xxxxxxx>
CC: stable@xxxxxxxxxx
---
 drivers/hid/hid-core.c        |    7 ++++++-
 drivers/hid/usbhid/hid-core.c |    2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index bd3971b..3f39383 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -731,7 +731,12 @@ static int hid_scan_report(struct hid_device *hid)
  */
 int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size)
 {
-	hid->dev_rdesc = kmemdup(start, size, GFP_KERNEL);
+	/*
+	 * this is called from post_reset() of usbhid
+	 * thus it may be part of the block error handling
+	 * GFP_NOIO must be used
+	 */
+	hid->dev_rdesc = kmemdup(start, size, GFP_NOIO);
 	if (!hid->dev_rdesc)
 		return -ENOMEM;
 	hid->dev_rsize = size;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 8e0c4bf94..c3f7144 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1415,7 +1415,7 @@ static int hid_post_reset(struct usb_interface *intf)
 	 * configuration descriptors passed, we already know that
 	 * the size of the HID report descriptor has not changed.
 	 */
-	rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL);
+	rdesc = kmalloc(hid->dev_rsize, GFP_NOIO);
 	if (!rdesc) {
 		dbg_hid("couldn't allocate rdesc memory (post_reset)\n");
 		return 1;
-- 
1.7.7

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux