[PATCH v3 06/10] mci: do not look up OF partitions for DT-less host controllers

Ahmad Fatoum a.fatoum at barebox.org
Mon Jun 29 05:45:25 PDT 2026


When mci_card_probe is called on a device that has been registered
without a device tree node, mci_get_partitions_node will end up with
a NULL pointer dereference inside of_get_child_by_name().

Other MCI code already handles this gracefully, so guard this code with
a NULL check as well.

While at it, rename the function to be more similar to existing
convention: Functions processing and manipulting the DT start with of_
instead of a trailing _node in their name.

Fixes: 6e9a87b39429 ("mci: Allow to partition eMMC boot partitions")
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
v2 -> v3:
  - split off NULL check into its own commit (Sascha)
  - renamed the function
---
 drivers/mci/mci-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 4413fd1655aa..874ee40cb3b4 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2935,14 +2935,14 @@ static const char *mci_boot_names[] = {
 	"user",
 };
 
-static struct device_node *mci_get_partition_node(struct device_node *hwnode,
-						  unsigned int type,
-						  unsigned int index)
+static struct device_node *of_mci_get_partition(struct device_node *hwnode,
+						unsigned int type,
+						unsigned int index)
 {
 	struct device_node *np;
 	char partnodename[sizeof("bootx-partitions")];
 
-	if (index > 8)
+	if (!hwnode || index > 8)
 		return NULL;
 
 	switch (type) {
@@ -3004,7 +3004,7 @@ static int mci_register_partition(struct mci_part *part)
 	}
 	dev_info(&mci->dev, "registered %s\n", part->blk.cdev.name);
 
-	np = mci_get_partition_node(host->hw_dev->of_node, part->area_type, part->idx);
+	np = of_mci_get_partition(host->hw_dev->of_node, part->area_type, part->idx);
 	if (np) {
 		of_parse_partitions(&part->blk.cdev, np);
 
-- 
2.47.3




More information about the barebox mailing list