diff options
author | Johan Hovold <jhovold@gmail.com> | 2012-10-25 04:29:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-25 12:36:58 -0400 |
commit | feffa7ca6008ab859dd7ab7448a5a899bf0aa98f (patch) | |
tree | 7e52c82145eab218089d75d44c2c181039af32cd /drivers/usb/serial/omninet.c | |
parent | 4230af572f95b3115bba1ee6fb95681f3851ab26 (diff) |
USB: omninet: fix port-data memory leak
Fix port-data memory leak by replacing attach and release with
port_probe and port_remove.
Since commit 0998d0631001288 (device-core: Ensure drvdata = NULL when no
driver is bound) the port private data is no longer freed at release as
it is no longer accessible.
Compile-only tested.
Cc: <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/omninet.c')
-rw-r--r-- | drivers/usb/serial/omninet.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 6def58b79382..9ab73d295774 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -44,8 +44,8 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
44 | const unsigned char *buf, int count); | 44 | const unsigned char *buf, int count); |
45 | static int omninet_write_room(struct tty_struct *tty); | 45 | static int omninet_write_room(struct tty_struct *tty); |
46 | static void omninet_disconnect(struct usb_serial *serial); | 46 | static void omninet_disconnect(struct usb_serial *serial); |
47 | static void omninet_release(struct usb_serial *serial); | 47 | static int omninet_port_probe(struct usb_serial_port *port); |
48 | static int omninet_attach(struct usb_serial *serial); | 48 | static int omninet_port_remove(struct usb_serial_port *port); |
49 | 49 | ||
50 | static const struct usb_device_id id_table[] = { | 50 | static const struct usb_device_id id_table[] = { |
51 | { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, | 51 | { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, |
@@ -62,7 +62,8 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
62 | .description = "ZyXEL - omni.net lcd plus usb", | 62 | .description = "ZyXEL - omni.net lcd plus usb", |
63 | .id_table = id_table, | 63 | .id_table = id_table, |
64 | .num_ports = 1, | 64 | .num_ports = 1, |
65 | .attach = omninet_attach, | 65 | .port_probe = omninet_port_probe, |
66 | .port_remove = omninet_port_remove, | ||
66 | .open = omninet_open, | 67 | .open = omninet_open, |
67 | .close = omninet_close, | 68 | .close = omninet_close, |
68 | .write = omninet_write, | 69 | .write = omninet_write, |
@@ -70,7 +71,6 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
70 | .read_bulk_callback = omninet_read_bulk_callback, | 71 | .read_bulk_callback = omninet_read_bulk_callback, |
71 | .write_bulk_callback = omninet_write_bulk_callback, | 72 | .write_bulk_callback = omninet_write_bulk_callback, |
72 | .disconnect = omninet_disconnect, | 73 | .disconnect = omninet_disconnect, |
73 | .release = omninet_release, | ||
74 | }; | 74 | }; |
75 | 75 | ||
76 | static struct usb_serial_driver * const serial_drivers[] = { | 76 | static struct usb_serial_driver * const serial_drivers[] = { |
@@ -112,18 +112,26 @@ struct omninet_data { | |||
112 | __u8 od_outseq; /* Sequence number for bulk_out URBs */ | 112 | __u8 od_outseq; /* Sequence number for bulk_out URBs */ |
113 | }; | 113 | }; |
114 | 114 | ||
115 | static int omninet_attach(struct usb_serial *serial) | 115 | static int omninet_port_probe(struct usb_serial_port *port) |
116 | { | 116 | { |
117 | struct omninet_data *od; | 117 | struct omninet_data *od; |
118 | struct usb_serial_port *port = serial->port[0]; | ||
119 | 118 | ||
120 | od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); | 119 | od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); |
121 | if (!od) { | 120 | if (!od) |
122 | dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", | ||
123 | __func__, sizeof(struct omninet_data)); | ||
124 | return -ENOMEM; | 121 | return -ENOMEM; |
125 | } | 122 | |
126 | usb_set_serial_port_data(port, od); | 123 | usb_set_serial_port_data(port, od); |
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int omninet_port_remove(struct usb_serial_port *port) | ||
129 | { | ||
130 | struct omninet_data *od; | ||
131 | |||
132 | od = usb_get_serial_port_data(port); | ||
133 | kfree(od); | ||
134 | |||
127 | return 0; | 135 | return 0; |
128 | } | 136 | } |
129 | 137 | ||
@@ -279,14 +287,6 @@ static void omninet_disconnect(struct usb_serial *serial) | |||
279 | usb_kill_urb(wport->write_urb); | 287 | usb_kill_urb(wport->write_urb); |
280 | } | 288 | } |
281 | 289 | ||
282 | |||
283 | static void omninet_release(struct usb_serial *serial) | ||
284 | { | ||
285 | struct usb_serial_port *port = serial->port[0]; | ||
286 | |||
287 | kfree(usb_get_serial_port_data(port)); | ||
288 | } | ||
289 | |||
290 | module_usb_serial_driver(serial_drivers, id_table); | 290 | module_usb_serial_driver(serial_drivers, id_table); |
291 | 291 | ||
292 | MODULE_AUTHOR(DRIVER_AUTHOR); | 292 | MODULE_AUTHOR(DRIVER_AUTHOR); |