Commit 97d0aa6b authored by Johan Hovold's avatar Johan Hovold Committed by Zefan Li

USB: serial: fix potential use-after-free after failed probe

commit 07fdfc5e upstream.

Fix return value in probe error path, which could end up returning
success (0) on errors. This could in turn lead to use-after-free or
double free (e.g. in port_remove) when the port device is removed.

Fixes: c706ebdf ("USB: usb-serial: call port_probe and port_remove
at the right times")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Acked-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
[lizf: Backported to 3.4: adjust context]
Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
parent a10ca36c
...@@ -71,7 +71,7 @@ static int usb_serial_device_probe(struct device *dev) ...@@ -71,7 +71,7 @@ static int usb_serial_device_probe(struct device *dev)
retval = device_create_file(dev, &dev_attr_port_number); retval = device_create_file(dev, &dev_attr_port_number);
if (retval) { if (retval) {
if (driver->port_remove) if (driver->port_remove)
retval = driver->port_remove(port); driver->port_remove(port);
goto exit; goto exit;
} }
......
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