ChangeSet 1.1455.1.41, 2003/07/17 14:46:56-07:00, henning@meier-geinitz.de

[PATCH] USB: unlink interrupt URBs in scanner driver

Clean up irq urb when not enough memory is available.


 drivers/usb/image/scanner.c |    7 +++++++
 1 files changed, 7 insertions(+)


diff -Nru a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c
--- a/drivers/usb/image/scanner.c	Thu Jul 17 17:03:20 2003
+++ b/drivers/usb/image/scanner.c	Thu Jul 17 17:03:20 2003
@@ -367,6 +367,7 @@
  * 0.4.14  2003-07-15
  *    - Fixed race between open and probe (Oliver Neukum).
  *    - Added vendor/product ids for Avision, Canon, HP, Microtek and Relisys scanners.
+ *    - Clean up irq urb when not enough memory is available.
  *
  * TODO
  *    - Performance
@@ -1072,6 +1073,9 @@
 /* Ok, now initialize all the relevant values */
 	if (!(scn->obuf = (char *)kmalloc(OBUF_SIZE, GFP_KERNEL))) {
 		err("probe_scanner(%d): Not enough memory for the output buffer.", intf->minor);
+		if (have_intr)
+			usb_unlink_urb(scn->scn_irq);
+		usb_free_urb(scn->scn_irq);
 		kfree(scn);
 		up(&scn_mutex);
 		return -ENOMEM;
@@ -1080,6 +1084,9 @@
 
 	if (!(scn->ibuf = (char *)kmalloc(IBUF_SIZE, GFP_KERNEL))) {
 		err("probe_scanner(%d): Not enough memory for the input buffer.", intf->minor);
+		if (have_intr)
+			usb_unlink_urb(scn->scn_irq);
+		usb_free_urb(scn->scn_irq);
 		kfree(scn->obuf);
 		kfree(scn);
 		up(&scn_mutex);