public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions()
@ 2012-09-25  9:57 Sachin Kamat
  2012-09-26 10:46 ` Sachin Kamat
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sachin Kamat @ 2012-09-25  9:57 UTC (permalink / raw)
  To: linux-mtd
  Cc: patches, sachin.kamat, dedekind1, Dmitry Eremin-Solenikov,
	Artem Bityutskiy, dwmw2

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@gmail.com>
Cc: Artem Bityutskiy <artem.bityutskiy@intel.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 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);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-10 14:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-25  9:57 [PATCH] mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions() Sachin Kamat
2012-09-26 10:46 ` Sachin Kamat
2012-09-26 11:11   ` Artem Bityutskiy
2012-10-01 18:11 ` Sachin Kamat
2012-10-10  7:51 ` Sachin Kamat
2012-10-10 14:36 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox