Commit 4901ee4e authored by Henning Meier-Geinitz's avatar Henning Meier-Geinitz Committed by Greg Kroah-Hartman

[PATCH] USB scanner driver: balancing usb_register_dev/usb_deregister_dev

Balancing usb_register_dev/usb_deregister_dev in probe_scanner when a
fail condition occours (Daniele Bellucci).
parent c9e5993d
...@@ -374,6 +374,8 @@ ...@@ -374,6 +374,8 @@
* (Daniele Bellucci). * (Daniele Bellucci).
* - Report back return codes of usb_register and usb_usbmit_urb instead of -1 or * - Report back return codes of usb_register and usb_usbmit_urb instead of -1 or
* -ENONMEM (Daniele Bellucci). * -ENONMEM (Daniele Bellucci).
* - Balancing usb_register_dev/usb_deregister_dev in probe_scanner when a fail
* condition occours (Daniele Bellucci).
* *
* *
* TODO * TODO
...@@ -1050,6 +1052,7 @@ probe_scanner(struct usb_interface *intf, ...@@ -1050,6 +1052,7 @@ probe_scanner(struct usb_interface *intf,
scn->scn_irq = usb_alloc_urb(0, GFP_KERNEL); scn->scn_irq = usb_alloc_urb(0, GFP_KERNEL);
if (!scn->scn_irq) { if (!scn->scn_irq) {
usb_deregister_dev(intf, &scanner_class);
kfree(scn); kfree(scn);
up(&scn_mutex); up(&scn_mutex);
return -ENOMEM; return -ENOMEM;
...@@ -1071,6 +1074,7 @@ probe_scanner(struct usb_interface *intf, ...@@ -1071,6 +1074,7 @@ probe_scanner(struct usb_interface *intf,
retval = usb_submit_urb(scn->scn_irq, GFP_KERNEL); retval = usb_submit_urb(scn->scn_irq, GFP_KERNEL);
if (retval) { if (retval) {
err("probe_scanner(%d): Unable to allocate INT URB.", intf->minor); err("probe_scanner(%d): Unable to allocate INT URB.", intf->minor);
usb_deregister_dev(intf, &scanner_class);
kfree(scn); kfree(scn);
up(&scn_mutex); up(&scn_mutex);
return retval; return retval;
...@@ -1084,6 +1088,7 @@ probe_scanner(struct usb_interface *intf, ...@@ -1084,6 +1088,7 @@ probe_scanner(struct usb_interface *intf,
if (have_intr) if (have_intr)
usb_unlink_urb(scn->scn_irq); usb_unlink_urb(scn->scn_irq);
usb_free_urb(scn->scn_irq); usb_free_urb(scn->scn_irq);
usb_deregister_dev(intf, &scanner_class);
kfree(scn); kfree(scn);
up(&scn_mutex); up(&scn_mutex);
return -ENOMEM; return -ENOMEM;
...@@ -1095,6 +1100,7 @@ probe_scanner(struct usb_interface *intf, ...@@ -1095,6 +1100,7 @@ probe_scanner(struct usb_interface *intf,
if (have_intr) if (have_intr)
usb_unlink_urb(scn->scn_irq); usb_unlink_urb(scn->scn_irq);
usb_free_urb(scn->scn_irq); usb_free_urb(scn->scn_irq);
usb_deregister_dev(intf, &scanner_class);
kfree(scn->obuf); kfree(scn->obuf);
kfree(scn); kfree(scn);
up(&scn_mutex); up(&scn_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment