Skip to contentSkip to conversation

USB: usbtouch: Prevent possible deadlock

PATCH In review Oliver Neukum 2 participants 3 messages Mar 12, 2010 – Mar 14, 2010 1 message not in the archive

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

PATCH 3/5 USB: usbtouch: Prevent possible deadlock

Quoted 1 line

From 5e4fc75d1031ca1c621c0f85cf1e903ffd8fb758 Mon Sep 17 00:00:00 2001

From: Oliver Neukum <[email protected]>
Date: Thu, 11 Mar 2010 15:06:51 +0100
Subject: [PATCH 3/5] USB: usbtouch: Prevent possible deadlock

For autosuspend memory in suspend/resume must be allocated with GFP_NOIO.

---
 drivers/input/touchscreen/usbtouchscreen.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
drivers/input/touchscreen/usbtouchscreen.c +7 -7
index 8836761..f15aa2e 100644
@@ -508,7 +508,7 @@ static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
 	int ret = -ENOMEM;
 	unsigned char *buf;
 
-	buf = kmalloc(2, GFP_KERNEL);
+	buf = kmalloc(2, GFP_NOIO);
 	if (!buf)
 		goto err_nobuf;
 	/* reset */
@@ -756,7 +756,7 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
 	if (!input_ep || !output_ep)
 		return -ENXIO;
 
-	buf = kmalloc(NEXIO_BUFSIZE, GFP_KERNEL);
+	buf = kmalloc(NEXIO_BUFSIZE, GFP_NOIO);
 	if (!buf)
 		goto out_buf;
 
@@ -788,11 +788,11 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
 		switch (buf[0]) {
 		case 0x83:	/* firmware version */
 			if (!firmware_ver)
-				firmware_ver = kstrdup(&buf[2], GFP_KERNEL);
+				firmware_ver = kstrdup(&buf[2], GFP_NOIO);
 			break;
 		case 0x84:	/* device name */
 			if (!device_name)
-				device_name = kstrdup(&buf[2], GFP_KERNEL);
+				device_name = kstrdup(&buf[2], GFP_NOIO);
 			break;
 		}
 	}
@@ -806,19 +806,19 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
 	/* prepare ACK URB */
 	ret = -ENOMEM;
 
-	usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
+	usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_NOIO);
 	if (!usbtouch->priv)
 		goto out_buf;
 
 	priv = usbtouch->priv;
 
-	priv->ack_buf = kmalloc(sizeof(nexio_ack_pkt), GFP_KERNEL);
+	priv->ack_buf = kmalloc(sizeof(nexio_ack_pkt), GFP_NOIO);
 	if (!priv->ack_buf)
 		goto err_priv;
 
 	memcpy(priv->ack_buf, nexio_ack_pkt, sizeof(nexio_ack_pkt));
 
-	priv->ack = usb_alloc_urb(0, GFP_KERNEL);
+	priv->ack = usb_alloc_urb(0, GFP_NOIO);
 	if (!priv->ack) {
 		dbg("%s - usb_alloc_urb failed: usbtouch->ack", __func__);
 		goto err_ack_buf;
Signature · 6 lines
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#1 lore raw

Hi Oliver,

Quoted 7 lines · Oliver Neukum

From 5e4fc75d1031ca1c621c0f85cf1e903ffd8fb758 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Thu, 11 Mar 2010 15:06:51 +0100
Subject: [PATCH 3/5] USB: usbtouch: Prevent possible deadlock

For autosuspend memory in suspend/resume must be allocated with GFP_NOIO.

I'd prefer if this change was folded into previous patch - there was no deadlock condition before you added reset_resume.

drivers/input/touchscreen/usbtouchscreen.c static int nexio_init(struct usbtouch_usb *usbtouch) · line 812

Quoted 9 lines
drivers/input/touchscreen/usbtouchscreen.c +1 -1
@@ -806,19 +806,19 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
 	/* prepare ACK URB */
 	ret = -ENOMEM;
 
-	usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
+	usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_NOIO);
 	if (!usbtouch->priv)
 		goto out_buf;
 

Remind me, how does ->exit() gets called in case of reset_resume? Otherwise it looks like ne are leaking memory...

Signature · 1 line
Dmitry

A message that is not in the archive (sent off-list or not yet received): 20100314085949.GC8226-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org

#3 lore raw

Am Sonntag, 14. März 2010 09:59:49 schrieb Dmitry Torokhov:

Quoted 5 lines
Quoted 2 lines

For autosuspend memory in suspend/resume must be allocated with GFP_NOIO.

I'd prefer if this change was folded into previous patch - there was no deadlock condition before you added reset_resume.

Rafael is working on automatically going to GFP_NOIO in case the system is resumed. The change will be needed for patch #4, not #2.

Quoted 4 lines
Quoted 4 lines
drivers/input/touchscreen/usbtouchscreen.c +0 -0
@@ -806,19 +806,19 @@ static int nexio_init(struct usbtouch_usb *usbtouch)
      /* prepare ACK URB */
      ret = -ENOMEM;
 
Quoted 8 lines

drivers/input/touchscreen/usbtouchscreen.c static int nexio_init(struct usbtouch_usb *usbtouch) · line 812

Quoted 5 lines
drivers/input/touchscreen/usbtouchscreen.c +1 -1
-     usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_KERNEL);
+     usbtouch->priv = kmalloc(sizeof(struct nexio_priv), GFP_NOIO);
      if (!usbtouch->priv)
              goto out_buf;
 

Remind me, how does ->exit() gets called in case of reset_resume? Otherwise it looks like ne are leaking memory...

Oh, I overlooked that they only free buf, not priv. I'll have to add a hook.

Thanks
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html