USB: mxu11x0: fix memory leak on usb_serial private data
On nominal execution, private data allocated on port_probe and attach are never freed. Add port_remove and release callbacks to free them respectively. Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
parent
e03cdf22a2
commit
028635d6b5
|
@ -368,6 +368,16 @@ static int mxu1_port_probe(struct usb_serial_port *port)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mxu1_port_remove(struct usb_serial_port *port)
|
||||||
|
{
|
||||||
|
struct mxu1_port *mxport;
|
||||||
|
|
||||||
|
mxport = usb_get_serial_port_data(port);
|
||||||
|
kfree(mxport);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int mxu1_startup(struct usb_serial *serial)
|
static int mxu1_startup(struct usb_serial *serial)
|
||||||
{
|
{
|
||||||
struct mxu1_device *mxdev;
|
struct mxu1_device *mxdev;
|
||||||
|
@ -427,6 +437,14 @@ err_free_mxdev:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mxu1_release(struct usb_serial *serial)
|
||||||
|
{
|
||||||
|
struct mxu1_device *mxdev;
|
||||||
|
|
||||||
|
mxdev = usb_get_serial_data(serial);
|
||||||
|
kfree(mxdev);
|
||||||
|
}
|
||||||
|
|
||||||
static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,
|
static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,
|
||||||
u8 mask, u8 byte)
|
u8 mask, u8 byte)
|
||||||
{
|
{
|
||||||
|
@ -957,7 +975,9 @@ static struct usb_serial_driver mxu11x0_device = {
|
||||||
.id_table = mxu1_idtable,
|
.id_table = mxu1_idtable,
|
||||||
.num_ports = 1,
|
.num_ports = 1,
|
||||||
.port_probe = mxu1_port_probe,
|
.port_probe = mxu1_port_probe,
|
||||||
|
.port_remove = mxu1_port_remove,
|
||||||
.attach = mxu1_startup,
|
.attach = mxu1_startup,
|
||||||
|
.release = mxu1_release,
|
||||||
.open = mxu1_open,
|
.open = mxu1_open,
|
||||||
.close = mxu1_close,
|
.close = mxu1_close,
|
||||||
.ioctl = mxu1_ioctl,
|
.ioctl = mxu1_ioctl,
|
||||||
|
|
Loading…
Reference in New Issue