aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2015-02-18 10:34:51 +0700
committerBen Hutchings <ben@decadent.org.uk>2015-05-09 23:16:21 +0100
commitffd9140bd28948bc7a419d92fdd1707db24d60aa (patch)
tree2d19d0cdf07117d3084590bcab078c0c4a149c12 /drivers/usb
parent7f073a838187213d46fdd4bc8f319ad6195165d2 (diff)
downloadkernel_samsung_smdk4412-ffd9140bd28948bc7a419d92fdd1707db24d60aa.zip
kernel_samsung_smdk4412-ffd9140bd28948bc7a419d92fdd1707db24d60aa.tar.gz
kernel_samsung_smdk4412-ffd9140bd28948bc7a419d92fdd1707db24d60aa.tar.bz2
USB: serial: fix tty-device error handling at probe
commit ca4383a3947a83286bc9b9c598a1f55e867871d7 upstream. Add missing error handling when registering the tty device at port probe. This avoids trying to remove an uninitialised character device when the port device is removed. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Greg Kroah-Hartman <greg@kroah.com> [bwh: Backported to 3.2: - Adjust context - No need to clean up autopm] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/bus.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 020b515..a8dc799 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -52,6 +52,7 @@ static int usb_serial_device_probe(struct device *dev)
{
struct usb_serial_driver *driver;
struct usb_serial_port *port;
+ struct device *tty_dev;
int retval = 0;
int minor;
@@ -78,7 +79,15 @@ static int usb_serial_device_probe(struct device *dev)
}
minor = port->number;
- tty_register_device(usb_serial_tty_driver, minor, dev);
+ tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev);
+ if (IS_ERR(tty_dev)) {
+ retval = PTR_ERR(tty_dev);
+ device_remove_file(dev, &dev_attr_port_number);
+ if (driver->port_remove)
+ driver->port_remove(port);
+ goto exit;
+ }
+
dev_info(&port->serial->dev->dev,
"%s converter now attached to ttyUSB%d\n",
driver->description, minor);