From: Sachin Kamat Date: Tue, 25 Sep 2012 09:57:13 +0000 (+0530) Subject: mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions() X-Git-Tag: next-20121019~48^2~22 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=52b11c45801bb5e6a3d10d6262f0dea89c006e0f;p=karo-tx-linux.git 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. Signed-off-by: Sachin Kamat Cc: stable@vger.kernel.org [3.2+] Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 64be8f0848b0..d9127e2ed808 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);