usb: gadget: configs: plug memory leak
authorJohn Keeping <john@metanate.com>
Tue, 28 Feb 2017 10:55:30 +0000 (10:55 +0000)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Mon, 6 Mar 2017 14:45:57 +0000 (16:45 +0200)
When binding a gadget to a device, "name" is stored in gi->udc_name, but
this does not happen when unregistering and the string is leaked.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/configfs.c

index 78c44979dde382ca8c58e9f9f84024180ce9663d..cbff3b02840df901ca0ca03c646b14f5f6085719 100644 (file)
@@ -269,6 +269,7 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
                ret = unregister_gadget(gi);
                if (ret)
                        goto err;
+               kfree(name);
        } else {
                if (gi->composite.gadget_driver.udc_name) {
                        ret = -EBUSY;