diff options
author | Johan Hovold <johan@kernel.org> | 2015-02-17 22:34:51 -0500 |
---|---|---|
committer | Johan Hovold <johan@kernel.org> | 2015-02-26 11:12:35 -0500 |
commit | ca4383a3947a83286bc9b9c598a1f55e867871d7 (patch) | |
tree | c0b86d4b4a723ac24a9ef5728560a54016fd4092 /drivers/usb | |
parent | 07fdfc5e9f1c966be8722e8fa927e5ea140df5ce (diff) |
USB: serial: fix tty-device error handling at probe
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>
Cc: stable <stable@vger.kernel.org> # v2.6.12
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/bus.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 5d8d86666b90..6f91eb9ae81a 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
@@ -51,6 +51,7 @@ static int usb_serial_device_probe(struct device *dev) | |||
51 | { | 51 | { |
52 | struct usb_serial_driver *driver; | 52 | struct usb_serial_driver *driver; |
53 | struct usb_serial_port *port; | 53 | struct usb_serial_port *port; |
54 | struct device *tty_dev; | ||
54 | int retval = 0; | 55 | int retval = 0; |
55 | int minor; | 56 | int minor; |
56 | 57 | ||
@@ -80,7 +81,15 @@ static int usb_serial_device_probe(struct device *dev) | |||
80 | } | 81 | } |
81 | 82 | ||
82 | minor = port->minor; | 83 | minor = port->minor; |
83 | tty_register_device(usb_serial_tty_driver, minor, dev); | 84 | tty_dev = tty_register_device(usb_serial_tty_driver, minor, dev); |
85 | if (IS_ERR(tty_dev)) { | ||
86 | retval = PTR_ERR(tty_dev); | ||
87 | device_remove_file(dev, &dev_attr_port_number); | ||
88 | if (driver->port_remove) | ||
89 | driver->port_remove(port); | ||
90 | goto exit_with_autopm; | ||
91 | } | ||
92 | |||
84 | dev_info(&port->serial->dev->dev, | 93 | dev_info(&port->serial->dev->dev, |
85 | "%s converter now attached to ttyUSB%d\n", | 94 | "%s converter now attached to ttyUSB%d\n", |
86 | driver->description, minor); | 95 | driver->description, minor); |