linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: net2280: fix memory leak on probe error handling paths
@ 2020-07-21 20:15 Evgeny Novikov
  2020-07-22 14:17 ` Alan Stern
  0 siblings, 1 reply; 7+ messages in thread
From: Evgeny Novikov @ 2020-07-21 20:15 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Evgeny Novikov, Greg Kroah-Hartman, Benjamin Herrenschmidt,
	Kees Cook, Arnd Bergmann, Corentin Labbe, linux-usb,
	linux-kernel, ldv-project

Driver does not release memory for device on error handling paths in
net2280_probe() when gadget_release() is not registered yet.

The patch fixes the bug like in other similar drivers.

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

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
---
 drivers/usb/gadget/udc/net2280.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 5eff85eeaa5a..d5fe071b2db2 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -3781,8 +3781,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	return 0;
 
 done:
-	if (dev)
+	if (dev) {
 		net2280_remove(pdev);
+		kfree(dev);
+	}
 	return retval;
 }
 
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-23  8:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 20:15 [PATCH] usb: gadget: net2280: fix memory leak on probe error handling paths Evgeny Novikov
2020-07-22 14:17 ` Alan Stern
2020-07-22 19:56   ` Evgeny Novikov
2020-07-23  0:59     ` Benjamin Herrenschmidt
2020-07-23  1:02       ` Alan Stern
2020-07-23  1:00     ` Alan Stern
2020-07-23  8:50       ` Evgeny Novikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).