mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: Fix memory leak in probe error path
@ 2023-03-03 13:43 Jules Maselbas
  2023-03-03 13:50 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Jules Maselbas @ 2023-03-03 13:43 UTC (permalink / raw)
  To: barebox; +Cc: Jules Maselbas

The dwc2 driver private structure wasn't freed in the error path.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/usb/dwc2/dwc2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index ef957534c9..ff4842ce62 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -92,11 +92,10 @@ static int dwc2_probe(struct device *dev)
 	set_params_cb set_params;
 	int ret;
 
-	dwc2 = xzalloc(sizeof(*dwc2));
-
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
+	dwc2 = xzalloc(sizeof(*dwc2));
 	dwc2->regs = IOMEM(iores->start);
 	dwc2->dev = dev;
 
@@ -177,6 +176,8 @@ clk_put:
 release_region:
 	release_region(iores);
 
+	free(dwc2);
+
 	return ret;
 }
 
-- 
2.17.1




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

end of thread, other threads:[~2023-03-03 13:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 13:43 [PATCH] usb: dwc2: Fix memory leak in probe error path Jules Maselbas
2023-03-03 13:50 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox