aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2012-10-17 07:35:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-10-17 16:47:58 -0400
commit94ab71ce288921490ca857e25ad174e1921b1e29 (patch)
treea3cb81a0ca06e355da92cffeba471efb1dd56699 /drivers
parent3124d1d71d3df59d40b913b5481df58099e811d1 (diff)
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 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. 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/serial/keyspan_pda.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index ca43ecb4a2bd..bb87e29c4ac2 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -713,29 +713,33 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
713MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 713MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
714#endif 714#endif
715 715
716static int keyspan_pda_startup(struct usb_serial *serial) 716static int keyspan_pda_port_probe(struct usb_serial_port *port)
717{ 717{
718 718
719 struct keyspan_pda_private *priv; 719 struct keyspan_pda_private *priv;
720 720
721 /* allocate the private data structures for all ports. Well, for all
722 one ports. */
723
724 priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); 721 priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
725 if (!priv) 722 if (!priv)
726 return 1; /* error */ 723 return -ENOMEM;
727 usb_set_serial_port_data(serial->port[0], priv); 724
728 init_waitqueue_head(&serial->port[0]->write_wait);
729 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); 725 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
730 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); 726 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
731 priv->serial = serial; 727 priv->serial = port->serial;
732 priv->port = serial->port[0]; 728 priv->port = port;
729
730 usb_set_serial_port_data(port, priv);
731
733 return 0; 732 return 0;
734} 733}
735 734
736static void keyspan_pda_release(struct usb_serial *serial) 735static int keyspan_pda_port_remove(struct usb_serial_port *port)
737{ 736{
738 kfree(usb_get_serial_port_data(serial->port[0])); 737 struct keyspan_pda_private *priv;
738
739 priv = usb_get_serial_port_data(port);
740 kfree(priv);
741
742 return 0;
739} 743}
740 744
741#ifdef KEYSPAN 745#ifdef KEYSPAN
@@ -786,8 +790,8 @@ static struct usb_serial_driver keyspan_pda_device = {
786 .break_ctl = keyspan_pda_break_ctl, 790 .break_ctl = keyspan_pda_break_ctl,
787 .tiocmget = keyspan_pda_tiocmget, 791 .tiocmget = keyspan_pda_tiocmget,
788 .tiocmset = keyspan_pda_tiocmset, 792 .tiocmset = keyspan_pda_tiocmset,
789 .attach = keyspan_pda_startup, 793 .port_probe = keyspan_pda_port_probe,
790 .release = keyspan_pda_release, 794 .port_remove = keyspan_pda_port_remove,
791}; 795};
792 796
793static struct usb_serial_driver * const serial_drivers[] = { 797static struct usb_serial_driver * const serial_drivers[] = {