usbtouchscreen: fix leaks and check return value of usb_submit_urb()
Subsystems (2)
PATCH 7/7 usbtouchscreen: fix leaks and check return value of usb_submit_urb()
From: Ondrej Zary <[email protected]>
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 <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Jim Persson <[email protected]>
Cc Florian Echtler <[email protected]>
Cc Dan Streetman <[email protected]>
Cc Daniel Ritz <[email protected]>
Cc Greg KH <[email protected]>
Cc Oliver Neukum <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/input/touchscreen/usbtouchscreen.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
drivers/input/touchscreen/usbtouchscreen.c renamed from drivers/input/touchscreen/usbtouchscreen.c~usbtouchscreen-fix-leaks-and-check-return-value-of-usb_submit_urb +17 -4
@@ -834,6 +834,7 @@ static void nexio_exit(struct usbtouch_uusb_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:
_