Re: [PATCH] usb: dwc2: Fix memory leak in probe error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux