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

* Re: [PATCH] usb: dwc2: Fix memory leak in probe error path
  2023-03-03 13:43 [PATCH] usb: dwc2: Fix memory leak in probe error path Jules Maselbas
@ 2023-03-03 13:50 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-03-03 13:50 UTC (permalink / raw)
  To: Jules Maselbas; +Cc: barebox

On Fri, Mar 03, 2023 at 02:43:21PM +0100, Jules Maselbas wrote:
> 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(-)

Applied, thanks

Sascha

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

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ 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