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.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: stable@vger.kernel.org [3.2+]
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
  • Loading branch information
Sachin Kamat authored and Artem Bityutskiy committed Nov 15, 2012
1 parent 0aa87b7 commit ecbcbc7
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 ecbcbc7

Please sign in to comment.