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

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: c706ebdfc8 ("USB: usb-serial: call port_probe and port_remove
at the right times")
Cc: stable <stable@vger.kernel.org>	# v2.6.31
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Johan Hovold 2015-02-18 10:34:50 +07:00
parent 5ee0089b1f
commit 07fdfc5e9f
1 changed files with 1 additions and 1 deletions

View File

@ -75,7 +75,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_with_autopm; goto exit_with_autopm;
} }