Patchwork usb: gadget: goku_udc: fix memory leak in goku_probe()

login
register
mail settings
Submitter Alexey Khoroshilov
Date Aug. 26, 2016, 12:06 a.m.
Message ID <1472169962-11714-1-git-send-email-khoroshilov@ispras.ru>
Download mbox | patch
Permalink /patch/9300735/
State New
Headers show

Comments

Alexey Khoroshilov - Aug. 26, 2016, 12:06 a.m.
Memory allocated for goku_udc device is not deallocated at error
paths in goku_probe(), because gadget_release() destructor
is not registered yet.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/usb/gadget/udc/goku_udc.c | 2 ++
 1 file changed, 2 insertions(+)

Patch

diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index d2205d9e0c8b..8b290c128d97 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -1839,6 +1839,8 @@  static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 err:
 	if (dev)
 		goku_remove (pdev);
+	/* gadget_release is not registered yet, kfree explicitly */
+	kfree(dev);
 	return retval;
 }