USB: serial: fix potential use-after-free after failed probe
authorJohan Hovold <johan@kernel.org>
Wed, 18 Feb 2015 03:34:50 +0000 (10:34 +0700)
committerJohan Hovold <johan@kernel.org>
Thu, 26 Feb 2015 16:08:36 +0000 (17:08 +0100)
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: c706ebdfc895 ("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>
drivers/usb/serial/bus.c

index 9374bd2aba20759f4bb4b03d2a9d51058aead9fd..5d8d86666b901d19cbdb99f382ac64b6d3f2ef7c 100644 (file)
@@ -75,7 +75,7 @@ static int usb_serial_device_probe(struct device *dev)
        retval = device_create_file(dev, &dev_attr_port_number);
        if (retval) {
                if (driver->port_remove)
-                       retval = driver->port_remove(port);
+                       driver->port_remove(port);
                goto exit_with_autopm;
        }