All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Opasiak <k.opasiak@samsung.com>
To: balbi@ti.com, mina86@mina86.com
Cc: stable@vger.kernel.org, david.fisher1@synopsys.com,
	gregkh@linuxfoundation.org, andrzej.p@samsung.com,
	m.szyprowski@samsung.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH v2 1/5] usb: gadget: mass_storage: Free buffers if create lun fails
Date: Thu, 02 Jul 2015 21:28:48 +0200	[thread overview]
Message-ID: <559590F0.9080002@samsung.com> (raw)
In-Reply-To: <1435863398-24646-2-git-send-email-k.opasiak@samsung.com>

Felippe,

Could you please take this patch as a fix now and leave the rest of this 
series to merge window or should I resend it separately?

On 07/02/2015 08:56 PM, 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@samsung.com>
> Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
>   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:
>

-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics

  reply	other threads:[~2015-07-02 19:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 18:56 [PATCH v2 0/5] Mass storage fixes and improvements Krzysztof Opasiak
2015-07-02 18:56 ` [PATCH v2 1/5] usb: gadget: mass_storage: Free buffers if create lun fails Krzysztof Opasiak
2015-07-02 19:28   ` Krzysztof Opasiak [this message]
2015-07-02 18:56 ` [PATCH v2 2/5] usb: gadget: mass_storage: Place EXPORT_SYMBOL_GPL() after func definition Krzysztof Opasiak
2015-07-02 18:56 ` [PATCH v2 3/5] usb: gadget: storage-common: Set FSG_MAX_LUNS to 16 Krzysztof Opasiak
2015-07-02 18:56 ` [PATCH v2 4/5] usb: gadget: mass_storage: Use static array for luns Krzysztof Opasiak
2015-07-02 19:29   ` Michal Nazarewicz
2015-07-02 19:40     ` Krzysztof Opasiak
2015-07-02 18:56 ` [PATCH v2 5/5] usb: gadget: mass_storage: Warn if LUNs ids are not contiguous Krzysztof Opasiak
2015-07-02 19:29   ` Michal Nazarewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559590F0.9080002@samsung.com \
    --to=k.opasiak@samsung.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=david.fisher1@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mina86@mina86.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.