summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2015-12-29 13:36:12 +0100
committerJohan Hovold <johan@kernel.org>2015-12-29 13:43:14 +0100
commite69f7a6724182e3f3a4f3d73e74c08dd8f657a9d (patch)
tree8398a7be960fe7d085a07edf1f58fe5396989e90 /drivers/usb
parent924eccc73db2f64a24865d21ff11be8043b24375 (diff)
USB: mxu11x0: fix memory leak on firmware download
Make sure to release the private data before returning -ENODEV after having downloaded the firmware during first probe. Clean up the error paths while at it. Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/mxu11x0.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/usb/serial/mxu11x0.c b/drivers/usb/serial/mxu11x0.c
index 89426c3eba98..c6c4776997fc 100644
--- a/drivers/usb/serial/mxu11x0.c
+++ b/drivers/usb/serial/mxu11x0.c
@@ -377,7 +377,6 @@ static int mxu1_startup(struct usb_serial *serial)
char fw_name[32];
const struct firmware *fw_p = NULL;
int err;
- int status = 0;
dev_dbg(&serial->interface->dev, "%s - product 0x%04X, num configurations %d, configuration value %d\n",
__func__, le16_to_cpu(dev->descriptor.idProduct),
@@ -407,22 +406,26 @@ static int mxu1_startup(struct usb_serial *serial)
if (err) {
dev_err(&serial->interface->dev, "failed to request firmware: %d\n",
err);
- kfree(mxdev);
- return err;
+ goto err_free_mxdev;
}
err = mxu1_download_firmware(serial, fw_p);
- if (err) {
- release_firmware(fw_p);
- kfree(mxdev);
- return err;
- }
+ if (err)
+ goto err_release_firmware;
- status = -ENODEV;
- release_firmware(fw_p);
+ /* device is being reset */
+ err = -ENODEV;
+ goto err_release_firmware;
}
- return status;
+ return 0;
+
+err_release_firmware:
+ release_firmware(fw_p);
+err_free_mxdev:
+ kfree(mxdev);
+
+ return err;
}
static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,