mtd: parsers: qcom: Fix kernel panic on skipped partition
authorAnsuel Smith <ansuelsmth@gmail.com>
Sun, 16 Jan 2022 03:22:10 +0000 (04:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 11:03:16 +0000 (12:03 +0100)
commiteb03cb6e03ffd9173e18e5fe87e4e3ce83820453
tree1c490bf71d5a340e1bd908c1d17599b2532eb542
parent502f86f5168adaa60fb1249e7a83465472409e52
mtd: parsers: qcom: Fix kernel panic on skipped partition

commit 65d003cca335cabc0160d3cd7daa689eaa9dd3cd upstream.

In the event of a skipped partition (case when the entry name is empty)
the kernel panics in the cleanup function as the name entry is NULL.
Rework the parser logic by first checking the real partition number and
then allocate the space and set the data for the valid partitions.

The logic was also fundamentally wrong as with a skipped partition, the
parts number returned was incorrect by not decreasing it for the skipped
partitions.

Fixes: 803eb124e1a6 ("mtd: parsers: Add Qcom SMEM parser")
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220116032211.9728-1-ansuelsmth@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/parsers/qcomsmempart.c