diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-07-20 20:15:17 +0200 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-07-29 09:59:19 -0500 |
commit | 903588a99c26ed6f103eaa0cfa4ccbe9cd779398 (patch) | |
tree | 4a761c5688f43bf48eb3636998aa0965fb9f64b3 /drivers/usb | |
parent | aa7399744dd02537523b7bf9e3070600b6f79751 (diff) | |
download | op-kernel-dev-903588a99c26ed6f103eaa0cfa4ccbe9cd779398.zip op-kernel-dev-903588a99c26ed6f103eaa0cfa4ccbe9cd779398.tar.gz |
usb: gadget: mass_storage: Free buffers if create lun fails
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@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/gadget/function/f_mass_storage.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index f936268..f72102a 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -3524,6 +3524,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); @@ -3534,6 +3537,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: |