mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
USB: keyspan_pda: 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.
Note that the write waitqueue was initialised but never used.
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
3124d1d71d
commit
94ab71ce28
1 changed files with 17 additions and 13 deletions
|
@ -713,29 +713,33 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
|
||||||
MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
|
MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int keyspan_pda_startup(struct usb_serial *serial)
|
static int keyspan_pda_port_probe(struct usb_serial_port *port)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct keyspan_pda_private *priv;
|
struct keyspan_pda_private *priv;
|
||||||
|
|
||||||
/* allocate the private data structures for all ports. Well, for all
|
|
||||||
one ports. */
|
|
||||||
|
|
||||||
priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
|
priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return 1; /* error */
|
return -ENOMEM;
|
||||||
usb_set_serial_port_data(serial->port[0], priv);
|
|
||||||
init_waitqueue_head(&serial->port[0]->write_wait);
|
|
||||||
INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
|
INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
|
||||||
INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
|
INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
|
||||||
priv->serial = serial;
|
priv->serial = port->serial;
|
||||||
priv->port = serial->port[0];
|
priv->port = port;
|
||||||
|
|
||||||
|
usb_set_serial_port_data(port, priv);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyspan_pda_release(struct usb_serial *serial)
|
static int keyspan_pda_port_remove(struct usb_serial_port *port)
|
||||||
{
|
{
|
||||||
kfree(usb_get_serial_port_data(serial->port[0]));
|
struct keyspan_pda_private *priv;
|
||||||
|
|
||||||
|
priv = usb_get_serial_port_data(port);
|
||||||
|
kfree(priv);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KEYSPAN
|
#ifdef KEYSPAN
|
||||||
|
@ -786,8 +790,8 @@ static struct usb_serial_driver keyspan_pda_device = {
|
||||||
.break_ctl = keyspan_pda_break_ctl,
|
.break_ctl = keyspan_pda_break_ctl,
|
||||||
.tiocmget = keyspan_pda_tiocmget,
|
.tiocmget = keyspan_pda_tiocmget,
|
||||||
.tiocmset = keyspan_pda_tiocmset,
|
.tiocmset = keyspan_pda_tiocmset,
|
||||||
.attach = keyspan_pda_startup,
|
.port_probe = keyspan_pda_port_probe,
|
||||||
.release = keyspan_pda_release,
|
.port_remove = keyspan_pda_port_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct usb_serial_driver * const serial_drivers[] = {
|
static struct usb_serial_driver * const serial_drivers[] = {
|
||||||
|
|
Loading…
Reference in a new issue