Commit 05d84306 authored by Johan Hovold's avatar Johan Hovold Committed by Ben Hutchings

USB: sierra: fix memory leak in attach error path

commit 7e41f9bc upstream.

Make sure port private data is deallocated on errors in attach.
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent ce834659
......@@ -937,7 +937,7 @@ static int sierra_startup(struct usb_serial *serial)
dev_dbg(&port->dev, "%s: kmalloc for "
"sierra_port_private (%d) failed!\n",
__func__, i);
return -ENOMEM;
goto err;
}
spin_lock_init(&portdata->lock);
init_usb_anchor(&portdata->active);
......@@ -974,6 +974,13 @@ static int sierra_startup(struct usb_serial *serial)
}
return 0;
err:
for (--i; i >= 0; --i) {
portdata = usb_get_serial_port_data(serial->port[i]);
kfree(portdata);
}
return -ENOMEM;
}
static void sierra_release(struct usb_serial *serial)
......
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