usb: gadget: configs: plug memory leak 02/218602/1
authorJohn Keeping <john@metanate.com>
Tue, 28 Feb 2017 10:55:30 +0000 (10:55 +0000)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 26 Nov 2019 02:24:59 +0000 (11:24 +0900)
[ Upstream commit 38355b2a44776c25b0f2ad466e8c51bb805b3032 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[dwoo08.lee: cherry-pick linux-4.9.y stable commit 59682e70c980 to stablize configfs]
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Change-Id: Ieb2bcfeed245a0b993ac6c4992af8fe27fc89d48

drivers/usb/gadget/configfs.c

index bd2149527ceb144d4c211318227b93f4cf4a4208..62bc1bc929f644657818cd5fba89104daf79cd2b 100644 (file)
@@ -339,6 +339,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;