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 0998d06310
(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>
This commit is contained in:
parent
5c1a0f418d
commit
95940a04bf
|
@ -54,8 +54,8 @@
|
||||||
|
|
||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
static int kobil_startup(struct usb_serial *serial);
|
static int kobil_port_probe(struct usb_serial_port *probe);
|
||||||
static void kobil_release(struct usb_serial *serial);
|
static int kobil_port_remove(struct usb_serial_port *probe);
|
||||||
static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
|
static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
|
||||||
static void kobil_close(struct usb_serial_port *port);
|
static void kobil_close(struct usb_serial_port *port);
|
||||||
static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
|
static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||||
|
@ -89,8 +89,8 @@ static struct usb_serial_driver kobil_device = {
|
||||||
.description = "KOBIL USB smart card terminal",
|
.description = "KOBIL USB smart card terminal",
|
||||||
.id_table = id_table,
|
.id_table = id_table,
|
||||||
.num_ports = 1,
|
.num_ports = 1,
|
||||||
.attach = kobil_startup,
|
.port_probe = kobil_port_probe,
|
||||||
.release = kobil_release,
|
.port_remove = kobil_port_remove,
|
||||||
.ioctl = kobil_ioctl,
|
.ioctl = kobil_ioctl,
|
||||||
.set_termios = kobil_set_termios,
|
.set_termios = kobil_set_termios,
|
||||||
.init_termios = kobil_init_termios,
|
.init_termios = kobil_init_termios,
|
||||||
|
@ -117,9 +117,10 @@ struct kobil_private {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int kobil_startup(struct usb_serial *serial)
|
static int kobil_port_probe(struct usb_serial_port *port)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
struct usb_serial *serial = port->serial;
|
||||||
struct kobil_private *priv;
|
struct kobil_private *priv;
|
||||||
struct usb_device *pdev;
|
struct usb_device *pdev;
|
||||||
struct usb_host_config *actconfig;
|
struct usb_host_config *actconfig;
|
||||||
|
@ -149,7 +150,7 @@ static int kobil_startup(struct usb_serial *serial)
|
||||||
dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n");
|
dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usb_set_serial_port_data(serial->port[0], priv);
|
usb_set_serial_port_data(port, priv);
|
||||||
|
|
||||||
/* search for the necessary endpoints */
|
/* search for the necessary endpoints */
|
||||||
pdev = serial->dev;
|
pdev = serial->dev;
|
||||||
|
@ -179,12 +180,14 @@ static int kobil_startup(struct usb_serial *serial)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void kobil_release(struct usb_serial *serial)
|
static int kobil_port_remove(struct usb_serial_port *port)
|
||||||
{
|
{
|
||||||
int i;
|
struct kobil_private *priv;
|
||||||
|
|
||||||
for (i = 0; i < serial->num_ports; ++i)
|
priv = usb_get_serial_port_data(port);
|
||||||
kfree(usb_get_serial_port_data(serial->port[i]));
|
kfree(priv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kobil_init_termios(struct tty_struct *tty)
|
static void kobil_init_termios(struct tty_struct *tty)
|
||||||
|
|
Loading…
Reference in New Issue