Re: [PATCH 1/5] usb: gadget: mass_storage: Free buffers if create lun fails

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

 



On Mon, Jun 22 2015, Krzysztof Opasiak wrote:
> Creation of LUN 0 may fail (for example due to ENOMEM).
> As fsg_common_set_num_buffers() does some memory allocation
> we should free it before it becomes unavailable.
>
> Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx> # 3.13+

Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx>

> ---
>  drivers/usb/gadget/function/f_mass_storage.c |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
> index 3cc109f..2e8f37e 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.c
> +++ b/drivers/usb/gadget/function/f_mass_storage.c
> @@ -3526,6 +3526,9 @@ static struct usb_function_instance *fsg_alloc_inst(void)
>  	config.removable = true;
>  	rc = fsg_common_create_lun(opts->common, &config, 0, "lun.0",
>  			(const char **)&opts->func_inst.group.cg_item.ci_name);
> +	if (rc)
> +		goto release_buffers;
> +
>  	opts->lun0.lun = opts->common->luns[0];
>  	opts->lun0.lun_id = 0;
>  	config_group_init_type_name(&opts->lun0.group, "lun.0", &fsg_lun_type);
> @@ -3536,6 +3539,8 @@ static struct usb_function_instance *fsg_alloc_inst(void)
>  
>  	return &opts->func_inst;
>  
> +release_buffers:
> +	fsg_common_free_buffers(opts->common);
>  release_luns:
>  	kfree(opts->common->luns);
>  release_opts:
> -- 
> 1.7.9.5
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@xxxxxxxxxx>--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in



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

  Powered by Linux