All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Nazarewicz" <m.nazarewicz@samsung.com>
To: Viral Mehta <Viral.Mehta@lntinfotech.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: Kyungmin Park <kyungmin.park@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] USB: gadget: f_mass_storage: fix in fsg_common_init() error recovery
Date: Wed, 12 May 2010 11:57:50 +0200	[thread overview]
Message-ID: <op.vck7aofj7p4s8u@pikus> (raw)
In-Reply-To: <70376CA23424B34D86F1C7DE6B9973430254343ABC@VSHINMSMBX01.vshodc.lntinfotech.com>

On Wed, 12 May 2010 11:36:06 +0200, Viral Mehta <Viral.Mehta@lntinfotech.com> wrote:
> diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
> index f4911c0..7ad9a89 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -2702,7 +2702,8 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
>         if (fsg_strings[FSG_STRING_INTERFACE].id == 0) {
>                 rc = usb_string_id(cdev);
>                 if (rc < 0) {
> -                       kfree(common);
> +                       if(common->free_storage_on_release)
> +                               kfree(common);
>                         return ERR_PTR(rc);
>                 }
>                 fsg_strings[FSG_STRING_INTERFACE].id = rc;
> @@ -2713,7 +2714,8 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
>          * LUN devices in sysfs. */
>         curlun = kzalloc(nluns * sizeof *curlun, GFP_KERNEL);
>         if (!curlun) {
> -               kfree(common);
> +               if(common->free_storage_on_release)
> +                       kfree(common);
>                 return ERR_PTR(-ENOMEM);
>         }
>         common->luns = curlun;
>
> looks correct and simple fix.

Yes, it should work fine and in fact was my first approach but as I've written in
my previous mail:

> The way I see it, it does not matter that much -- it's error recovery so we assume
> it's unlikely to happen and as such speed optimisation is not really needed here --
> it's better to optimise for space and minimise the number of possible paths.

Because of that, I the "goto error_release" to be cleaner in the sense that
there is a single error recovery path and only one place where
free_storage_on_release flag is checked and common freed.

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--

  reply	other threads:[~2010-05-12  9:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12  8:16 [PATCH] USB: gadget: f_mass_storage: fix in fsg_common_init() error recovery Michal Nazarewicz
2010-05-12  8:29 ` Viral Mehta
2010-05-12  9:02   ` Michał Nazarewicz
2010-05-12  9:28     ` Viral Mehta
2010-05-12  9:36       ` Viral Mehta
2010-05-12  9:57         ` Michał Nazarewicz [this message]
2010-05-12 10:33           ` Viral Mehta
2010-05-12 10:51             ` [PATCH] USB: gadget: f_mass_storage: fix in " Michal Nazarewicz
2010-05-12 12:03               ` Viral Mehta
2010-05-12 21:39               ` Greg KH
2010-05-12 22:16                 ` Michal Nazarewicz
2010-05-12  9:53       ` [PATCH] USB: gadget: f_mass_storage: fix in fsg_common_init() " Michał Nazarewicz
2010-05-12 10:06         ` Viral Mehta
2010-05-12 10:34           ` Michał Nazarewicz
2010-05-12 10:37             ` Viral Mehta
2010-05-12 10:52               ` Michał 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=op.vck7aofj7p4s8u@pikus \
    --to=m.nazarewicz@samsung.com \
    --cc=Viral.Mehta@lntinfotech.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /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.