summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/bus.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2015-02-18 10:34:52 +0700
committerJohan Hovold <johan@kernel.org>2015-02-26 17:12:46 +0100
commit2deb96b5d4bb20a33bfaf80e30f38f3433653054 (patch)
treed02b859829f986671780463141d4d227f991fbf3 /drivers/usb/serial/bus.c
parentca4383a3947a83286bc9b9c598a1f55e867871d7 (diff)
downloadop-kernel-dev-2deb96b5d4bb20a33bfaf80e30f38f3433653054.zip
op-kernel-dev-2deb96b5d4bb20a33bfaf80e30f38f3433653054.tar.gz
USB: serial: fix port attribute-creation race
Fix attribute-creation race with userspace by using the port device groups field to create the port attributes. Also use %u when printing the port number, which is unsigned, even though we do not currently support more than 128 ports per device. Reported-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/usb/serial/bus.c')
-rw-r--r--drivers/usb/serial/bus.c19
1 files changed, 0 insertions, 19 deletions
diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
index 6f91eb9..b53a286 100644
--- a/drivers/usb/serial/bus.c
+++ b/drivers/usb/serial/bus.c
@@ -38,15 +38,6 @@ static int usb_serial_device_match(struct device *dev,
return 0;
}
-static ssize_t port_number_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct usb_serial_port *port = to_usb_serial_port(dev);
-
- return sprintf(buf, "%d\n", port->port_number);
-}
-static DEVICE_ATTR_RO(port_number);
-
static int usb_serial_device_probe(struct device *dev)
{
struct usb_serial_driver *driver;
@@ -73,18 +64,10 @@ static int usb_serial_device_probe(struct device *dev)
goto exit_with_autopm;
}
- retval = device_create_file(dev, &dev_attr_port_number);
- if (retval) {
- if (driver->port_remove)
- driver->port_remove(port);
- goto exit_with_autopm;
- }
-
minor = port->minor;
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;
@@ -123,8 +106,6 @@ static int usb_serial_device_remove(struct device *dev)
minor = port->minor;
tty_unregister_device(usb_serial_tty_driver, minor);
- device_remove_file(&port->dev, &dev_attr_port_number);
-
driver = port->serial->type;
if (driver->port_remove)
retval = driver->port_remove(port);
OpenPOWER on IntegriCloud