Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e69f7a67 authored by Johan Hovold's avatar Johan Hovold
Browse files

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: default avatarJohan Hovold <johan@kernel.org>
parent 924eccc7
Loading
Loading
Loading
Loading
+14 −11
Original line number Original line Diff line number Diff line
@@ -377,7 +377,6 @@ static int mxu1_startup(struct usb_serial *serial)
	char fw_name[32];
	char fw_name[32];
	const struct firmware *fw_p = NULL;
	const struct firmware *fw_p = NULL;
	int err;
	int err;
	int status = 0;


	dev_dbg(&serial->interface->dev, "%s - product 0x%04X, num configurations %d, configuration value %d\n",
	dev_dbg(&serial->interface->dev, "%s - product 0x%04X, num configurations %d, configuration value %d\n",
		__func__, le16_to_cpu(dev->descriptor.idProduct),
		__func__, le16_to_cpu(dev->descriptor.idProduct),
@@ -407,22 +406,26 @@ static int mxu1_startup(struct usb_serial *serial)
		if (err) {
		if (err) {
			dev_err(&serial->interface->dev, "failed to request firmware: %d\n",
			dev_err(&serial->interface->dev, "failed to request firmware: %d\n",
				err);
				err);
			kfree(mxdev);
			goto err_free_mxdev;
			return err;
		}
		}


		err = mxu1_download_firmware(serial, fw_p);
		err = mxu1_download_firmware(serial, fw_p);
		if (err) {
		if (err)
			release_firmware(fw_p);
			goto err_release_firmware;
			kfree(mxdev);

			return err;
		/* device is being reset */
		err = -ENODEV;
		goto err_release_firmware;
	}
	}


		status = -ENODEV;
	return 0;

err_release_firmware:
	release_firmware(fw_p);
	release_firmware(fw_p);
	}
err_free_mxdev:
	kfree(mxdev);


	return status;
	return err;
}
}


static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,
static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,