From patchwork Tue Sep 25 09:57:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions() From: Sachin Kamat X-Patchwork-Id: 186752 Message-Id: <1348567033-5418-1-git-send-email-sachin.kamat@linaro.org> To: linux-mtd@lists.infradead.org Cc: patches@linaro.org, sachin.kamat@linaro.org, dedekind1@gmail.com, Dmitry Eremin-Solenikov , Artem Bityutskiy , dwmw2@infradead.org Date: Tue, 25 Sep 2012 15:27:13 +0530 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 Cc: Artem Bityutskiy Signed-off-by: Sachin Kamat --- 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);