mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
USB: serial: fix tty-device error handling at probe
commitca4383a394upstream. 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:1da177e4c3("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0db70c6d0c
commit
a2cfb7dc7d
@@ -51,6 +51,7 @@ static int usb_serial_device_probe(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct usb_serial_driver *driver;
|
struct usb_serial_driver *driver;
|
||||||
struct usb_serial_port *port;
|
struct usb_serial_port *port;
|
||||||
|
struct device *tty_dev;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
int minor;
|
int minor;
|
||||||
|
|
||||||
@@ -80,7 +81,15 @@ static int usb_serial_device_probe(struct device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
minor = port->minor;
|
minor = port->minor;
|
||||||
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_with_autopm;
|
||||||
|
}
|
||||||
|
|
||||||
dev_info(&port->serial->dev->dev,
|
dev_info(&port->serial->dev->dev,
|
||||||
"%s converter now attached to ttyUSB%d\n",
|
"%s converter now attached to ttyUSB%d\n",
|
||||||
driver->description, minor);
|
driver->description, minor);
|
||||||
|
|||||||
Reference in New Issue
Block a user