[U-Boot] [PATCH v2 6/9] usb: kbd: Fix memleak on usb_kbd_deregister()
Hans de Goede
hdegoede at redhat.com
Wed Sep 24 14:06:08 CEST 2014
Free the keyboard hid-report buffer and private data on deregister.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
common/usb_kbd.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index cb869ac..253530a 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -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
--
2.1.0
More information about the U-Boot
mailing list