]> git.sur5r.net Git - u-boot/commitdiff
usb: kbd: Fix memleak on usb_kbd_deregister()
authorHans de Goede <hdegoede@redhat.com>
Wed, 24 Sep 2014 12:06:08 +0000 (14:06 +0200)
committerMarek Vasut <marex@denx.de>
Tue, 4 Nov 2014 05:04:00 +0000 (06:04 +0100)
Free the keyboard hid-report buffer and private data on deregister.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
common/usb_kbd.c

index cb869acfb74264777617064ca2e1310037d9cf14..253530a1b6e6799b21675f78041f368cd81d7903 100644 (file)
@@ -524,9 +524,19 @@ int drv_usb_kbd_init(void)
 int usb_kbd_deregister(int force)
 {
 #ifdef CONFIG_SYS_STDIO_DEREGISTER
-       int ret = stdio_deregister(DEVNAME, force);
-       if (ret && ret != -ENODEV)
-               return ret;
+       struct stdio_dev *dev;
+       struct usb_device *usb_kbd_dev;
+       struct usb_kbd_pdata *data;
+
+       dev = stdio_get_by_name(DEVNAME);
+       if (dev) {
+               usb_kbd_dev = (struct usb_device *)dev->priv;
+               data = usb_kbd_dev->privptr;
+               if (stdio_deregister_dev(dev, force) != 0)
+                       return 1;
+               free(data->new);
+               free(data);
+       }
 
        return 0;
 #else