Skip to contentSkip to conversation

usb: gadget: configs: plug memory leak

PATCH In review John Keeping 2 participants 2 messages Feb 28, 2017 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: configs: plug memory leak

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.

---
 drivers/usb/gadget/configfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/configfs.c +1 -0
index 78c44979dde3..cbff3b02840d 100644
@@ -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;
Signature · 1 line
2.12.0.rc2.230.ga28edc07cd.dirty
#1 lore raw
Quoted 13 lines · John Keeping

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.

---
 drivers/usb/gadget/configfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/configfs.c +0 -0
index 78c44979dde3..cbff3b02840d 100644

drivers/usb/gadget/configfs.c static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, · line 272

Quoted 4 lines
drivers/usb/gadget/configfs.c +1 -0
@@ -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);

Looks correct to me.

Suzuki