[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <op.vck7aofj7p4s8u@pikus>
Date: Wed, 12 May 2010 11:57:50 +0200
From: Michał Nazarewicz <m.nazarewicz@...sung.com>
To: Viral Mehta <Viral.Mehta@...infotech.com>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>
Cc: Kyungmin Park <kyungmin.park@...sung.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] USB: gadget: f_mass_storage: fix in fsg_common_init()
error recovery
On Wed, 12 May 2010 11:36:06 +0200, Viral Mehta <Viral.Mehta@...infotech.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--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists