mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci: fix NULL pointer dereference
@ 2025-04-30 12:11 Michael Tretter
  0 siblings, 0 replies; only message in thread
From: Michael Tretter @ 2025-04-30 12:11 UTC (permalink / raw)
  To: barebox; +Cc: Michael Tretter

Calling `devlookup -k` directly on an mmc device instead of an partition
causes a NULL pointer dereference for cdevm.

Return a NULL pointer in this case to signal the error.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 drivers/mci/mci-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 592543faa7b8..abcda497646d 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2536,6 +2536,9 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
 	if (mci_part->area_type != MMC_BLK_DATA_AREA_MAIN)
 		return NULL;
 
+	if (!cdevm)
+		return NULL;
+
 	id = of_alias_get_id(cdev_of_node(cdevm), "mmc");
 	if (id < 0)
 		return NULL;
-- 
2.39.5




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-04-30 12:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-30 12:11 [PATCH] mci: fix NULL pointer dereference Michael Tretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox