USB: serial: fix interface refcounting

commit d7971051e4df825e0bc11b995e87bfe86355b8e5 upstream.

Make sure the interface is not released before our serial device.

Note that drivers are still not allowed to access the interface in
any way that may interfere with another driver that may have gotten
bound to the same interface after disconnect returns.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Johan Hovold 2013-03-19 09:21:09 +01:00 committed by Greg Kroah-Hartman
parent 10a00e38f3
commit cbff2b6d37
1 changed files with 2 additions and 1 deletions

View File

@ -168,6 +168,7 @@ static void destroy_serial(struct kref *kref)
} }
} }
usb_put_intf(serial->interface);
usb_put_dev(serial->dev); usb_put_dev(serial->dev);
kfree(serial); kfree(serial);
} }
@ -625,7 +626,7 @@ static struct usb_serial *create_serial(struct usb_device *dev,
} }
serial->dev = usb_get_dev(dev); serial->dev = usb_get_dev(dev);
serial->type = driver; serial->type = driver;
serial->interface = interface; serial->interface = usb_get_intf(interface);
kref_init(&serial->kref); kref_init(&serial->kref);
mutex_init(&serial->disc_mutex); mutex_init(&serial->disc_mutex);
serial->minor = SERIAL_TTY_NO_MINOR; serial->minor = SERIAL_TTY_NO_MINOR;