* [PATCH] block: partitions: of: Fix NULL dereference on partition without reg
@ 2026-07-17 14:26 Loic Poulain
0 siblings, 0 replies; only message in thread
From: Loic Poulain @ 2026-07-17 14:26 UTC (permalink / raw)
To: Jens Axboe, Christian Marangi
Cc: linux-block, linux-kernel, stable, Bartosz Golaszewski, Loic Poulain
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")
Cc: stable@vger.kernel.org
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
---
block/partitions/of.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/partitions/of.c b/block/partitions/of.c
index 53664ea06b6540e3d1155141adaafac7286f2d21..dab36513eba336344c9558d486a8915624b0fca8 100644
--- a/block/partitions/of.c
+++ b/block/partitions/of.c
@@ -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,
--
Loic Poulain <loic.poulain@oss.qualcomm.com>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-17 14:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-17 14:26 [PATCH] block: partitions: of: Fix NULL dereference on partition without reg Loic Poulain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®