block: partitions: of: Fix NULL dereference on partition without reg
Subsystems (2)
PATCH 1/1 block: partitions: of: Fix NULL dereference on partition without reg
A child node of a fixed-partitions node may lack a reg property, either because it is malformed or because it is not a partition entry at all. In that case of_get_property() returns NULL to reg, which is then dereferenced without proper checking.
Fixes 2e3a191e89f9 ("block: add support for partition table defined in OF")
Reviewed-by Bartosz Golaszewski <[email protected]>
Signed-off-by Loic Poulain <[email protected]>
--- block/partitions/of.c | 3 +++ 1 file changed, 3 insertions(+)
block/partitions/of.c +3 -0
@@ -15,6 +15,9 @@ static int validate_of_partition(struct device_node *np, int slot)int a_cells =of_n_addr_cells (np);int s_cells =of_n_size_cells (np); +if (!reg) +return -EINVAL ; +/* Make sure reg len match the expected addr and size cells */ if (len /sizeof (*reg) != a_cells + s_cells)return -EINVAL ;
---
base-commit: fce2dfa773ced15f27dd27cd0b482a7473cdcf2a
change-id: 20260717-partition-null-b05e2c956ee7
Best regards,
Signature · 1 line
Loic Poulain <[email protected]>