Эх сурвалжийг харах

HiSax: fix error checking for hisax_register()]

This patch (as875) adds error-checking to the callers of hisax_register().
It also changes an error pathway in that routine, making it return an error
code rather than 0.

This fixes Bugzilla #7960.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Karsten Keil <kkeil@suse.de>
Cc: Martin Bachem <info@colognechip.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Alan Stern 18 жил өмнө
parent
commit
ae2d990eed

+ 1 - 1
drivers/isdn/hisax/config.c

@@ -1551,7 +1551,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
 	if (retval == 0) { // yuck
 	if (retval == 0) { // yuck
 		cards[i].typ = 0;
 		cards[i].typ = 0;
 		nrcards--;
 		nrcards--;
-		return retval;
+		return -EINVAL;
 	}
 	}
 	cs = cards[i].cs;
 	cs = cards[i].cs;
 	hisax_d_if->cs = cs;
 	hisax_d_if->cs = cs;

+ 18 - 25
drivers/isdn/hisax/hfc_usb.c

@@ -485,7 +485,6 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
 {
 {
 	int k;
 	int k;
 
 
-	spin_lock_init(&urb->lock);
 	urb->dev = dev;
 	urb->dev = dev;
 	urb->pipe = pipe;
 	urb->pipe = pipe;
 	urb->complete = complete;
 	urb->complete = complete;
@@ -578,16 +577,14 @@ stop_isoc_chain(usb_fifo * fifo)
 			    "HFC-S USB: Stopping iso chain for fifo %i.%i",
 			    "HFC-S USB: Stopping iso chain for fifo %i.%i",
 			    fifo->fifonum, i);
 			    fifo->fifonum, i);
 #endif
 #endif
-			usb_unlink_urb(fifo->iso[i].purb);
+			usb_kill_urb(fifo->iso[i].purb);
 			usb_free_urb(fifo->iso[i].purb);
 			usb_free_urb(fifo->iso[i].purb);
 			fifo->iso[i].purb = NULL;
 			fifo->iso[i].purb = NULL;
 		}
 		}
 	}
 	}
-	if (fifo->urb) {
-		usb_unlink_urb(fifo->urb);
-		usb_free_urb(fifo->urb);
-		fifo->urb = NULL;
-	}
+	usb_kill_urb(fifo->urb);
+	usb_free_urb(fifo->urb);
+	fifo->urb = NULL;
 	fifo->active = 0;
 	fifo->active = 0;
 }
 }
 
 
@@ -1305,7 +1302,11 @@ usb_init(hfcusb_data * hfc)
 	}
 	}
 	/* default Prot: EURO ISDN, should be a module_param */
 	/* default Prot: EURO ISDN, should be a module_param */
 	hfc->protocol = 2;
 	hfc->protocol = 2;
-	hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol);
+	i = hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol);
+	if (i) {
+		printk(KERN_INFO "HFC-S USB: hisax_register -> %d\n", i);
+		return i;
+	}
 
 
 #ifdef CONFIG_HISAX_DEBUG
 #ifdef CONFIG_HISAX_DEBUG
 	hfc_debug = debug;
 	hfc_debug = debug;
@@ -1626,11 +1627,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
 #endif
 #endif
 			/* init the chip and register the driver */
 			/* init the chip and register the driver */
 			if (usb_init(context)) {
 			if (usb_init(context)) {
-				if (context->ctrl_urb) {
-					usb_unlink_urb(context->ctrl_urb);
-					usb_free_urb(context->ctrl_urb);
-					context->ctrl_urb = NULL;
-				}
+				usb_kill_urb(context->ctrl_urb);
+				usb_free_urb(context->ctrl_urb);
+				context->ctrl_urb = NULL;
 				kfree(context);
 				kfree(context);
 				return (-EIO);
 				return (-EIO);
 			}
 			}
@@ -1682,21 +1681,15 @@ hfc_usb_disconnect(struct usb_interface
 				    i);
 				    i);
 #endif
 #endif
 			}
 			}
-			if (context->fifos[i].urb) {
-				usb_unlink_urb(context->fifos[i].urb);
-				usb_free_urb(context->fifos[i].urb);
-				context->fifos[i].urb = NULL;
-			}
+			usb_kill_urb(context->fifos[i].urb);
+			usb_free_urb(context->fifos[i].urb);
+			context->fifos[i].urb = NULL;
 		}
 		}
 		context->fifos[i].active = 0;
 		context->fifos[i].active = 0;
 	}
 	}
-	/* wait for all URBS to terminate */
-	mdelay(10);
-	if (context->ctrl_urb) {
-		usb_unlink_urb(context->ctrl_urb);
-		usb_free_urb(context->ctrl_urb);
-		context->ctrl_urb = NULL;
-	}
+	usb_kill_urb(context->ctrl_urb);
+	usb_free_urb(context->ctrl_urb);
+	context->ctrl_urb = NULL;
 	hisax_unregister(&context->d_if);
 	hisax_unregister(&context->d_if);
 	kfree(context);		/* free our structure again */
 	kfree(context);		/* free our structure again */
 }				/* hfc_usb_disconnect */
 }				/* hfc_usb_disconnect */

+ 5 - 1
drivers/isdn/hisax/hisax_fcpcipnp.c

@@ -859,7 +859,11 @@ new_adapter(void)
 	for (i = 0; i < 2; i++)
 	for (i = 0; i < 2; i++)
 		b_if[i] = &adapter->bcs[i].b_if;
 		b_if[i] = &adapter->bcs[i].b_if;
 
 
-	hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp", protocol);
+	if (hisax_register(&adapter->isac.hisax_d_if, b_if, "fcpcipnp",
+			protocol) != 0) {
+		kfree(adapter);
+		adapter = NULL;
+	}
 
 
 	return adapter;
 	return adapter;
 }
 }

+ 6 - 1
drivers/isdn/hisax/st5481_init.c

@@ -107,12 +107,17 @@ static int probe_st5481(struct usb_interface *intf,
 	for (i = 0; i < 2; i++)
 	for (i = 0; i < 2; i++)
 		b_if[i] = &adapter->bcs[i].b_if;
 		b_if[i] = &adapter->bcs[i].b_if;
 
 
-	hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb", protocol);
+	if (hisax_register(&adapter->hisax_d_if, b_if, "st5481_usb",
+			protocol) != 0)
+		goto err_b1;
+
 	st5481_start(adapter);
 	st5481_start(adapter);
 
 
 	usb_set_intfdata(intf, adapter);
 	usb_set_intfdata(intf, adapter);
 	return 0;
 	return 0;
 
 
+ err_b1:
+	st5481_release_b(&adapter->bcs[1]);
  err_b:
  err_b:
 	st5481_release_b(&adapter->bcs[0]);
 	st5481_release_b(&adapter->bcs[0]);
  err_d:
  err_d:

+ 0 - 1
drivers/isdn/hisax/st5481_usb.c

@@ -407,7 +407,6 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev,
 {
 {
 	int k;
 	int k;
 
 
-	spin_lock_init(&urb->lock);
 	urb->dev=dev;
 	urb->dev=dev;
 	urb->pipe=pipe;
 	urb->pipe=pipe;
 	urb->interval = 1;
 	urb->interval = 1;