From: Michael Tretter <m.tretter@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH] mci: fix NULL pointer dereference
Date: Wed, 30 Apr 2025 14:11:12 +0200 [thread overview]
Message-ID: <20250430121112.2899908-1-m.tretter@pengutronix.de> (raw)
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
reply other threads:[~2025-04-30 12:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250430121112.2899908-1-m.tretter@pengutronix.de \
--to=m.tretter@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox