Commit c02c0249 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

usb: cdc-acm: make sure a refcount is taken early enough

commit c52873e5 upstream.

destroy() will decrement the refcount on the interface, so that
it needs to be taken so early that it never undercounts.

Fixes: 7fb57a01 ("USB: cdc-acm: Fix potential deadlock (lockdep warning)")
Cc: stable <stable@vger.kernel.org>
Reported-and-tested-by: syzbot+1b2449b7b5dc240d107a@syzkaller.appspotmail.com
Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
Link: https://lore.kernel.org/r/20190808142119.7998-1-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f417f971
...@@ -1333,10 +1333,6 @@ static int acm_probe(struct usb_interface *intf, ...@@ -1333,10 +1333,6 @@ static int acm_probe(struct usb_interface *intf,
tty_port_init(&acm->port); tty_port_init(&acm->port);
acm->port.ops = &acm_port_ops; acm->port.ops = &acm_port_ops;
minor = acm_alloc_minor(acm);
if (minor < 0)
goto alloc_fail1;
ctrlsize = usb_endpoint_maxp(epctrl); ctrlsize = usb_endpoint_maxp(epctrl);
readsize = usb_endpoint_maxp(epread) * readsize = usb_endpoint_maxp(epread) *
(quirks == SINGLE_RX_URB ? 1 : 2); (quirks == SINGLE_RX_URB ? 1 : 2);
...@@ -1344,6 +1340,13 @@ static int acm_probe(struct usb_interface *intf, ...@@ -1344,6 +1340,13 @@ static int acm_probe(struct usb_interface *intf,
acm->writesize = usb_endpoint_maxp(epwrite) * 20; acm->writesize = usb_endpoint_maxp(epwrite) * 20;
acm->control = control_interface; acm->control = control_interface;
acm->data = data_interface; acm->data = data_interface;
usb_get_intf(acm->control); /* undone in destruct() */
minor = acm_alloc_minor(acm);
if (minor < 0)
goto alloc_fail1;
acm->minor = minor; acm->minor = minor;
acm->dev = usb_dev; acm->dev = usb_dev;
if (h.usb_cdc_acm_descriptor) if (h.usb_cdc_acm_descriptor)
...@@ -1490,7 +1493,6 @@ static int acm_probe(struct usb_interface *intf, ...@@ -1490,7 +1493,6 @@ static int acm_probe(struct usb_interface *intf,
usb_driver_claim_interface(&acm_driver, data_interface, acm); usb_driver_claim_interface(&acm_driver, data_interface, acm);
usb_set_intfdata(data_interface, acm); usb_set_intfdata(data_interface, acm);
usb_get_intf(control_interface);
tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor, tty_dev = tty_port_register_device(&acm->port, acm_tty_driver, minor,
&control_interface->dev); &control_interface->dev);
if (IS_ERR(tty_dev)) { if (IS_ERR(tty_dev)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment