Re: [PATCH 1/2] usb: gadget: f_midi: Fix memleak in f_midi_alloc

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

 



On 20-11-16 20:17:09, Zhang Qilong wrote:
> In the error path, if midi is not null, we should to
> free the midi->id if necessary to prevent memleak.
> 
> Fixes: b85e9de9e818d ("usb: gadget: f_midi: convert to new function interface with backward compatibility")
> Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
> Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/f_midi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
> index 85cb15734aa8..596fd7ce56fb 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -1345,7 +1345,10 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
>  
>  setup_fail:
>  	mutex_unlock(&opts->lock);
> +	if (midi)
> +		kfree(midi->id);
>  	kfree(midi);
> +
>  	return ERR_PTR(status);
>  }
>  

It is better to add another goto label for this memory free.

-- 

Thanks,
Peter Chen



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

  Powered by Linux