mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Oct 10 04:59:01 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=5a6ea4af0907f995dc06df21a9c9ef764c7cd3bc
Commit:     5a6ea4af0907f995dc06df21a9c9ef764c7cd3bc
Parent:     bc86cf7af2ebda88056538e8edff852ee627f76a
Author:     Sachin Kamat <sachin.kamat at linaro.org>
AuthorDate: Tue Sep 25 15:27:13 2012 +0530
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Wed Oct 10 09:12:39 2012 +0100

    mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions()
    
    The pointer returned by kzalloc should be tested for NULL
    to avoid potential NULL pointer dereference later. Incorrect
    pointer was being tested for NULL. Bug introduced by commit fbcf62a3
    (mtd: physmap_of: move parse_obsolete_partitions to become separate
    parser).
    This patch fixes this bug.
    
    Cc: Dmitry Eremin-Solenikov <dbaryshkov at gmail.com>
    Cc: Artem Bityutskiy <artem.bityutskiy at intel.com>
    Cc: stable at kernel.org
    Signed-off-by: Sachin Kamat <sachin.kamat at linaro.org>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/ofpart.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 64be8f0..d9127e2 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
 	nr_parts = plen / sizeof(part[0]);
 
 	*pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
-	if (!pparts)
+	if (!*pparts)
 		return -ENOMEM;
 
 	names = of_get_property(dp, "partition-names", &plen);



More information about the linux-mtd-cvs mailing list