Skip to content

Commit

Permalink
mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sachin Kamat authored and David Woodhouse committed Oct 10, 2012
1 parent bc86cf7 commit 5a6ea4a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/ofpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5a6ea4a

Please sign in to comment.