Re: [PATCH v2 2/2] usb: gadget: Fix memleak in gadgetfs_fill_super

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

 



On Tue, Nov 17, 2020 at 10:16:29AM +0800, Zhang Qilong wrote:
> usb_get_gadget_udc_name will alloc memory for CHIP
> in "Enomem" branch. we should free it before error
> returns to prevent memleak.
> 
> Fixes: 175f712119c57 ("usb: gadget: provide interface for legacy gadgets to get UDC name")
> Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
> Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
> ---

Acked-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

> Changelog:
> v2
> - replace free with kfree.
> ---
>  drivers/usb/gadget/legacy/inode.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
> index 1b430b36d0a6..71e7d10dd76b 100644
> --- a/drivers/usb/gadget/legacy/inode.c
> +++ b/drivers/usb/gadget/legacy/inode.c
> @@ -2039,6 +2039,9 @@ gadgetfs_fill_super (struct super_block *sb, struct fs_context *fc)
>  	return 0;
>  
>  Enomem:
> +	kfree(CHIP);
> +	CHIP = NULL;
> +
>  	return -ENOMEM;
>  }
>  




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux