lkml.org 
[lkml]   [2010]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] USB: gadget: f_mass_storage: fix in fsg_common_init() error recovery
On Wed, 12 May 2010 12:06:11 +0200, Viral Mehta <Viral.Mehta@lntinfotech.com> wrote:
> In fsg_common_release(), we are freeing common->luns.
> 2894 kfree(common->luns);
>
> However, these gets allocd in fsg_common_init()
> 2712 /* Create the LUNs, open their backing files, and register the
> 2713 * LUN devices in sysfs. */
> 2714 curlun = kzalloc(nluns * sizeof *curlun, GFP_KERNEL);
> 2715 if (!curlun) {
> 2716 kfree(common);
> 2717 return ERR_PTR(-ENOMEM);
> 2718 }
>
> Now, if this kzalloc at line 2714 failed
> And if your patch is applied, you will follow error_release path which in
> turn will call kfree on a pointer whose allocation is failed.

If luns allocation fails, common->luns will be NULL and freeing a NULL
pointer is a no-operation thus the code works just fine.

--
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-05-12 12:35    [W:0.054 / U:0.184 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site