Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: serial: clean up bus probe error handling

Clean up bus probe error handling by separating success and error paths.

Signed-off-by: Johan Hovold <johan@kernel.org>

+14 -11
+14 -11
drivers/usb/serial/bus.c
··· 47 47 int minor; 48 48 49 49 port = to_usb_serial_port(dev); 50 - if (!port) { 51 - retval = -ENODEV; 52 - goto exit; 53 - } 50 + if (!port) 51 + return -ENODEV; 54 52 55 53 /* make sure suspend/resume doesn't race against port_probe */ 56 54 retval = usb_autopm_get_interface(port->serial->interface); 57 55 if (retval) 58 - goto exit; 56 + return retval; 59 57 60 58 driver = port->serial->type; 61 59 if (driver->port_probe) { 62 60 retval = driver->port_probe(port); 63 61 if (retval) 64 - goto exit_with_autopm; 62 + goto err_autopm_put; 65 63 } 66 64 67 65 minor = port->minor; 68 66 tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev); 69 67 if (IS_ERR(tty_dev)) { 70 68 retval = PTR_ERR(tty_dev); 71 - if (driver->port_remove) 72 - driver->port_remove(port); 73 - goto exit_with_autopm; 69 + goto err_port_remove; 74 70 } 71 + 72 + usb_autopm_put_interface(port->serial->interface); 75 73 76 74 dev_info(&port->serial->dev->dev, 77 75 "%s converter now attached to ttyUSB%d\n", 78 76 driver->description, minor); 79 77 80 - exit_with_autopm: 78 + return 0; 79 + 80 + err_port_remove: 81 + if (driver->port_remove) 82 + driver->port_remove(port); 83 + err_autopm_put: 81 84 usb_autopm_put_interface(port->serial->interface); 82 - exit: 85 + 83 86 return retval; 84 87 } 85 88