* [patch 8/8] usbtouchscreen: fix leaks and check return value of usb_submit_urb()
@ 2009-12-22 0:23 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2009-12-22 0:23 UTC (permalink / raw)
To: dtor
Cc: linux-input, akpm, linux, daniel.ritz, ddstreet, dmitry.torokhov,
floe, greg, jim-linux, oliver
From: Ondrej Zary <linux@rainbow-software.org>
Fix urb and priv leaks in error paths of initialization and NEXIO ack_buf
leak.
Also check usb_submit_urb() return value.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jim Persson <jim-linux@nurd.se>
Cc: Florian Echtler <floe@butterbrot.org>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Daniel Ritz <daniel.ritz@gmx.ch>
Cc: Greg KH <greg@kroah.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/input/touchscreen/usbtouchscreen.c | 21 +++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff -puN drivers/input/touchscreen/usbtouchscreen.c~usbtouchscreen-fix-leaks-and-check-return-value-of-usb_submit_urb drivers/input/touchscreen/usbtouchscreen.c
--- a/drivers/input/touchscreen/usbtouchscreen.c~usbtouchscreen-fix-leaks-and-check-return-value-of-usb_submit_urb
+++ a/drivers/input/touchscreen/usbtouchscreen.c
@@ -834,6 +834,7 @@ static void nexio_exit(struct usbtouch_u
usb_kill_urb(priv->ack);
usb_free_urb(priv->ack);
+ kfree(priv->ack_buf);
kfree(priv);
}
@@ -1395,23 +1396,35 @@ static int usbtouch_probe(struct usb_int
err = type->init(usbtouch);
if (err) {
dbg("%s - type->init() failed, err: %d", __func__, err);
- goto out_free_buffers;
+ goto out_free_urb;
}
}
err = input_register_device(usbtouch->input);
if (err) {
dbg("%s - input_register_device failed, err: %d", __func__, err);
- goto out_free_buffers;
+ goto out_exit;
}
usb_set_intfdata(intf, usbtouch);
- if (usbtouch->type->irq_always)
- usb_submit_urb(usbtouch->irq, GFP_KERNEL);
+ if (usbtouch->type->irq_always) {
+ err = usb_submit_urb(usbtouch->irq, GFP_KERNEL);
+ if (err) {
+ err("%s - usb_submit_urb failed with result: %d",
+ __func__, err);
+ input_unregister_device(usbtouch->input);
+ goto out_exit;
+ }
+ }
return 0;
+out_exit:
+ if (type->exit)
+ type->exit(usbtouch);
+out_free_urb:
+ usb_free_urb(usbtouch->irq);
out_free_buffers:
usbtouch_free_buffers(udev, usbtouch);
out_free:
_
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-12-22 0:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-22 0:23 [patch 8/8] usbtouchscreen: fix leaks and check return value of usb_submit_urb() akpm
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).