Commit ecbcbc7b75bb1b7596fca2d588d2f7539dc4e581

Authored by Sachin Kamat
Committed by Artem Bityutskiy
1 parent 0aa87b7563

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 fbcf62a3
(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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/mtd/ofpart.c
... ... @@ -121,7 +121,7 @@
121 121 nr_parts = plen / sizeof(part[0]);
122 122  
123 123 *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
124   - if (!pparts)
  124 + if (!*pparts)
125 125 return -ENOMEM;
126 126  
127 127 names = of_get_property(dp, "partition-names", &plen);