OSDN Git Service

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)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 25 Jan 2022 09:31:44 +0000 (10:31 +0100)
commit65d003cca335cabc0160d3cd7daa689eaa9dd3cd
tree10f56395411626bc6718d2a923de89a80d25720e
parent079e6bdb2b1cc1da8b5c602229db782732668ae7
mtd: parsers: qcom: Fix kernel panic on skipped partition

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
drivers/mtd/parsers/qcomsmempart.c