Skip to content

Commit 5a6ea4a

Browse files
Sachin KamatDavid Woodhouse
authored andcommitted
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 fbcf62a (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> Cc: stable@kernel.org Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent bc86cf7 commit 5a6ea4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/mtd/ofpart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
121121
nr_parts = plen / sizeof(part[0]);
122122

123123
*pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
124-
if (!pparts)
124+
if (!*pparts)
125125
return -ENOMEM;
126126

127127
names = of_get_property(dp, "partition-names", &plen);

0 commit comments

Comments
 (0)