Skip to contentSkip to conversation

- missing check in usb/serial/usb-serial.c.

PATCH Applied Luiz Fernando N. Capitulino 2 participants 2 messages Sep 13, 2004 – Sep 14, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 - missing check in usb/serial/usb-serial.c.

Hi Greg,

This patch add a missing check in the call to bus_register() and
not initialise `result' (which is not necessary).

 drivers/usb/serial/usb-serial.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
drivers/usb/serial/usb-serial.c +13 -6
diff -X /home/capitulino/kernels/2.6/dontdiff -Nparu a/drivers/usb/serial/usb-serial.c a~/drivers/usb/serial/usb-serial.c
@@ -1229,7 +1229,7 @@ struct tty_driver *usb_serial_tty_driver
 static int __init usb_serial_init(void)
 {
 	int i;
-	int result = 0;
+	int result;
 
 	usb_serial_tty_driver = alloc_tty_driver(SERIAL_TTY_MINORS);
 	if (!usb_serial_tty_driver)
@@ -1240,13 +1240,17 @@ static int __init usb_serial_init(void)
 		serial_table[i] = NULL;
 	}
 
-	bus_register(&usb_serial_bus_type);
+	result = bus_register(&usb_serial_bus_type);
+	if (result) {
+		err("%s - registering bus driver failed", __FUNCTION__);
+		goto exit_bus;
+	}
 
 	/* register the generic driver, if we should */
 	result = usb_serial_generic_register(debug);
 	if (result < 0) {
 		err("%s - registering generic driver failed", __FUNCTION__);
-		goto exit;
+		goto exit_generic;
 	}
 
 	usb_serial_tty_driver->owner = THIS_MODULE;
@@ -1264,7 +1268,7 @@ static int __init usb_serial_init(void)
 	result = tty_register_driver(usb_serial_tty_driver);
 	if (result) {
 		err("%s - tty_register_driver failed", __FUNCTION__);
-		goto exit_generic;
+		goto exit_reg_driver;
 	}
 
 	/* register the USB driver */
@@ -1281,10 +1285,13 @@ static int __init usb_serial_init(void)
 exit_tty:
 	tty_unregister_driver(usb_serial_tty_driver);
 
-exit_generic:
+exit_reg_driver:
 	usb_serial_generic_deregister();
 
-exit:
+exit_generic:
+	bus_unregister(&usb_serial_bus_type);
+
+exit_bus:
 	err ("%s - returning with error %d", __FUNCTION__, result);
 	put_tty_driver(usb_serial_tty_driver);
 	return result;
Applied
#1 lore raw
Quoted 5 lines · Luiz Fernando N. Capitulino

Hi Greg,

This patch add a missing check in the call to bus_register() and
not initialise `result' (which is not necessary).

Applied, thanks.

greg k-h