Commit c2fef456 authored by Johan Hovold's avatar Johan Hovold

USB: serial: clean up probe error paths

Clean up the probe error paths by adding a couple of new error labels.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent f1ce25f2
...@@ -752,8 +752,8 @@ static int usb_serial_probe(struct usb_interface *interface, ...@@ -752,8 +752,8 @@ static int usb_serial_probe(struct usb_interface *interface,
serial = create_serial(dev, interface, type); serial = create_serial(dev, interface, type);
if (!serial) { if (!serial) {
module_put(type->driver.owner); retval = -ENOMEM;
return -ENOMEM; goto err_put_module;
} }
/* if this device type has a probe function, call it */ /* if this device type has a probe function, call it */
...@@ -765,9 +765,7 @@ static int usb_serial_probe(struct usb_interface *interface, ...@@ -765,9 +765,7 @@ static int usb_serial_probe(struct usb_interface *interface,
if (retval) { if (retval) {
dev_dbg(ddev, "sub driver rejected device\n"); dev_dbg(ddev, "sub driver rejected device\n");
usb_serial_put(serial); goto err_put_serial;
module_put(type->driver.owner);
return retval;
} }
} }
...@@ -849,9 +847,8 @@ static int usb_serial_probe(struct usb_interface *interface, ...@@ -849,9 +847,8 @@ static int usb_serial_probe(struct usb_interface *interface,
*/ */
if (num_bulk_in == 0 || num_bulk_out == 0) { if (num_bulk_in == 0 || num_bulk_out == 0) {
dev_info(ddev, "PL-2303 hack: descriptors matched but endpoints did not\n"); dev_info(ddev, "PL-2303 hack: descriptors matched but endpoints did not\n");
usb_serial_put(serial); retval = -ENODEV;
module_put(type->driver.owner); goto err_put_serial;
return -ENODEV;
} }
} }
/* END HORRIBLE HACK FOR PL2303 */ /* END HORRIBLE HACK FOR PL2303 */
...@@ -862,9 +859,8 @@ static int usb_serial_probe(struct usb_interface *interface, ...@@ -862,9 +859,8 @@ static int usb_serial_probe(struct usb_interface *interface,
num_ports = num_bulk_out; num_ports = num_bulk_out;
if (num_ports == 0) { if (num_ports == 0) {
dev_err(ddev, "Generic device with no bulk out, not allowed.\n"); dev_err(ddev, "Generic device with no bulk out, not allowed.\n");
usb_serial_put(serial); retval = -EIO;
module_put(type->driver.owner); goto err_put_serial;
return -EIO;
} }
dev_info(ddev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n"); dev_info(ddev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n");
dev_info(ddev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n"); dev_info(ddev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n");
...@@ -1085,9 +1081,13 @@ static int usb_serial_probe(struct usb_interface *interface, ...@@ -1085,9 +1081,13 @@ static int usb_serial_probe(struct usb_interface *interface,
return 0; return 0;
probe_error: probe_error:
retval = -EIO;
err_put_serial:
usb_serial_put(serial); usb_serial_put(serial);
err_put_module:
module_put(type->driver.owner); module_put(type->driver.owner);
return -EIO;
return retval;
} }
static void usb_serial_disconnect(struct usb_interface *interface) static void usb_serial_disconnect(struct usb_interface *interface)
......
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