mtd: mtd_blkdevs: fix double free on error path

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Mar 11 10:59:01 EST 2011


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=bd637f6f22235b4613f9ab6555e8088a455c1ed4
Commit:     bd637f6f22235b4613f9ab6555e8088a455c1ed4
Parent:     82013d988fc03a1b908b2b0360a1e34f6152fda6
Author:     Maxim Levitsky <maximlevitsky at gmail.com>
AuthorDate: Sun Jan 9 01:25:06 2011 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Mar 11 14:19:44 2011 +0000

    mtd: mtd_blkdevs: fix double free on error path
    
    This one liner patch fixes double free that will occur if add_mtd_blktrans_dev
    fails. On failure it frees the input argument, but all its users also free it
    on error which is natural thing to do. Thus don't free it.
    
    All credit for finding that bug belongs to reporters of the bug in the android bugzilla
    http://code.google.com/p/android/issues/detail?id=13761
    
    Commit message tweaked by Artem.
    
    Signed-off-by: Maxim Levitsky <maximlevitsky at gmail.com>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
    Cc: stable at kernel.org
---
 drivers/mtd/mtd_blkdevs.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index cb20c67..e0a2373 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -413,7 +413,6 @@ error3:
 error2:
 	list_del(&new->list);
 error1:
-	kfree(new);
 	return ret;
 }
 



More information about the linux-mtd-cvs mailing list