Thread (255 messages) 255 messages, 5 authors, 2013-01-14
STALE4914d

[PATCH 103/241] mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions()

From: Herton Ronaldo Krzesinski <hidden>
Date: 2012-12-13 14:07:14
Also in: lkml
Subsystem: memory technology devices (mtd), the rest · Maintainers: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, Linus Torvalds

3.5.7.2 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sachin Kamat <redacted>

commit 5a6ea4af0907f995dc06df21a9c9ef764c7cd3bc upstream.

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 <redacted>
Cc: Artem Bityutskiy <redacted>
Signed-off-by: Sachin Kamat <redacted>
Signed-off-by: David Woodhouse <redacted>
Signed-off-by: Herton Ronaldo Krzesinski <redacted>
---
 drivers/mtd/ofpart.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
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.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help