linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/RFT 3/5] USB: usbtouch: Prevent possible deadlock
@ 2010-03-12 14:42 Oliver Neukum
  2010-03-14  8:59 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Neukum @ 2010-03-12 14:42 UTC (permalink / raw)
  To: Daniel Ritz; +Cc: linux-input-u79uwXL29TY76Z2rM5mHXA, USB list

>From 5e4fc75d1031ca1c621c0f85cf1e903ffd8fb758 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
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.

Signed-off-by: Oliver Neukum <neukum-shG/GajIFYqbacvFa/9K2g@public.gmane.org>
---
 drivers/input/touchscreen/usbtouchscreen.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 8836761..f15aa2e 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -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;
-- 
1.6.4.2

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC/RFT 3/5] USB: usbtouch: Prevent possible deadlock
  2010-03-12 14:42 [RFC/RFT 3/5] USB: usbtouch: Prevent possible deadlock Oliver Neukum
@ 2010-03-14  8:59 ` Dmitry Torokhov
       [not found]   ` <20100314085949.GC8226-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2010-03-14  8:59 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: Daniel Ritz, linux-input, USB list

Hi Oliver,

On Fri, Mar 12, 2010 at 03:42:53PM +0100, Oliver Neukum wrote:
> From 5e4fc75d1031ca1c621c0f85cf1e903ffd8fb758 Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oliver@neukum.org>
> 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.

> @@ -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...

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC/RFT 3/5] USB: usbtouch: Prevent possible deadlock
       [not found]   ` <20100314085949.GC8226-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
@ 2010-03-14  9:12     ` Oliver Neukum
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Neukum @ 2010-03-14  9:12 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Daniel Ritz, linux-input-u79uwXL29TY76Z2rM5mHXA, USB list

Am Sonntag, 14. März 2010 09:59:49 schrieb Dmitry Torokhov:
> > 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.
 
> > @@ -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...

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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-14  9:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-12 14:42 [RFC/RFT 3/5] USB: usbtouch: Prevent possible deadlock Oliver Neukum
2010-03-14  8:59 ` Dmitry Torokhov
     [not found]   ` <20100314085949.GC8226-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2010-03-14  9:12     ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).