aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu OTHACEHE <m.othacehe@gmail.com>2016-01-04 13:49:36 -0500
committerJohan Hovold <johan@kernel.org>2016-01-25 06:47:47 -0500
commit028635d6b5b42de0e0fe5f5c92e1b99868e81a29 (patch)
tree7e59c255d1595674a638d708cfcf7c9e953f8678
parente03cdf22a2727c60307be6a729233edab3bfda9c (diff)
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>
-rw-r--r--drivers/usb/serial/mxu11x0.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/usb/serial/mxu11x0.c b/drivers/usb/serial/mxu11x0.c
index e3c3f57c2d82..619607323bfd 100644
--- a/drivers/usb/serial/mxu11x0.c
+++ b/drivers/usb/serial/mxu11x0.c
@@ -368,6 +368,16 @@ static int mxu1_port_probe(struct usb_serial_port *port)
368 return 0; 368 return 0;
369} 369}
370 370
371static int mxu1_port_remove(struct usb_serial_port *port)
372{
373 struct mxu1_port *mxport;
374
375 mxport = usb_get_serial_port_data(port);
376 kfree(mxport);
377
378 return 0;
379}
380
371static int mxu1_startup(struct usb_serial *serial) 381static int mxu1_startup(struct usb_serial *serial)
372{ 382{
373 struct mxu1_device *mxdev; 383 struct mxu1_device *mxdev;
@@ -427,6 +437,14 @@ err_free_mxdev:
427 return err; 437 return err;
428} 438}
429 439
440static void mxu1_release(struct usb_serial *serial)
441{
442 struct mxu1_device *mxdev;
443
444 mxdev = usb_get_serial_data(serial);
445 kfree(mxdev);
446}
447
430static int mxu1_write_byte(struct usb_serial_port *port, u32 addr, 448static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,
431 u8 mask, u8 byte) 449 u8 mask, u8 byte)
432{ 450{
@@ -957,7 +975,9 @@ static struct usb_serial_driver mxu11x0_device = {
957 .id_table = mxu1_idtable, 975 .id_table = mxu1_idtable,
958 .num_ports = 1, 976 .num_ports = 1,
959 .port_probe = mxu1_port_probe, 977 .port_probe = mxu1_port_probe,
978 .port_remove = mxu1_port_remove,
960 .attach = mxu1_startup, 979 .attach = mxu1_startup,
980 .release = mxu1_release,
961 .open = mxu1_open, 981 .open = mxu1_open,
962 .close = mxu1_close, 982 .close = mxu1_close,
963 .ioctl = mxu1_ioctl, 983 .ioctl = mxu1_ioctl,