diff options
author | Johan Hovold <jhovold@gmail.com> | 2012-10-17 07:35:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-17 16:47:58 -0400 |
commit | 95940a04bfe8a4d246f4ca17c6a3b00148bdead0 (patch) | |
tree | 26b5d3f12c178bdb0e8f82cd5c3d4596b96f6f56 /drivers/usb | |
parent | 5c1a0f418d8d985f3a62849bcac43fc5404cc592 (diff) |
USB: kobil_sct: 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')
-rw-r--r-- | drivers/usb/serial/kobil_sct.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 5c4d2fbd4e11..c9ca7a5b12e0 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -54,8 +54,8 @@ | |||
54 | 54 | ||
55 | 55 | ||
56 | /* Function prototypes */ | 56 | /* Function prototypes */ |
57 | static int kobil_startup(struct usb_serial *serial); | 57 | static int kobil_port_probe(struct usb_serial_port *probe); |
58 | static void kobil_release(struct usb_serial *serial); | 58 | static int kobil_port_remove(struct usb_serial_port *probe); |
59 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); | 59 | static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); |
60 | static void kobil_close(struct usb_serial_port *port); | 60 | static void kobil_close(struct usb_serial_port *port); |
61 | static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, | 61 | static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, |
@@ -89,8 +89,8 @@ static struct usb_serial_driver kobil_device = { | |||
89 | .description = "KOBIL USB smart card terminal", | 89 | .description = "KOBIL USB smart card terminal", |
90 | .id_table = id_table, | 90 | .id_table = id_table, |
91 | .num_ports = 1, | 91 | .num_ports = 1, |
92 | .attach = kobil_startup, | 92 | .port_probe = kobil_port_probe, |
93 | .release = kobil_release, | 93 | .port_remove = kobil_port_remove, |
94 | .ioctl = kobil_ioctl, | 94 | .ioctl = kobil_ioctl, |
95 | .set_termios = kobil_set_termios, | 95 | .set_termios = kobil_set_termios, |
96 | .init_termios = kobil_init_termios, | 96 | .init_termios = kobil_init_termios, |
@@ -117,9 +117,10 @@ struct kobil_private { | |||
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | static int kobil_startup(struct usb_serial *serial) | 120 | static int kobil_port_probe(struct usb_serial_port *port) |
121 | { | 121 | { |
122 | int i; | 122 | int i; |
123 | struct usb_serial *serial = port->serial; | ||
123 | struct kobil_private *priv; | 124 | struct kobil_private *priv; |
124 | struct usb_device *pdev; | 125 | struct usb_device *pdev; |
125 | struct usb_host_config *actconfig; | 126 | struct usb_host_config *actconfig; |
@@ -149,7 +150,7 @@ static int kobil_startup(struct usb_serial *serial) | |||
149 | dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); | 150 | dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); |
150 | break; | 151 | break; |
151 | } | 152 | } |
152 | usb_set_serial_port_data(serial->port[0], priv); | 153 | usb_set_serial_port_data(port, priv); |
153 | 154 | ||
154 | /* search for the necessary endpoints */ | 155 | /* search for the necessary endpoints */ |
155 | pdev = serial->dev; | 156 | pdev = serial->dev; |
@@ -179,12 +180,14 @@ static int kobil_startup(struct usb_serial *serial) | |||
179 | } | 180 | } |
180 | 181 | ||
181 | 182 | ||
182 | static void kobil_release(struct usb_serial *serial) | 183 | static int kobil_port_remove(struct usb_serial_port *port) |
183 | { | 184 | { |
184 | int i; | 185 | struct kobil_private *priv; |
185 | 186 | ||
186 | for (i = 0; i < serial->num_ports; ++i) | 187 | priv = usb_get_serial_port_data(port); |
187 | kfree(usb_get_serial_port_data(serial->port[i])); | 188 | kfree(priv); |
189 | |||
190 | return 0; | ||
188 | } | 191 | } |
189 | 192 | ||
190 | static void kobil_init_termios(struct tty_struct *tty) | 193 | static void kobil_init_termios(struct tty_struct *tty) |