usb: gadget: goku_udc: fix memory leak in goku_probe()
diff mbox series

Message ID 1472169962-11714-1-git-send-email-khoroshilov@ispras.ru
State New, archived
Headers show
Series
  • usb: gadget: goku_udc: fix memory leak in goku_probe()
Related show

Commit Message

Alexey Khoroshilov Aug. 26, 2016, 12:06 a.m. UTC
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 mbox series

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;
 }