From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Florian Otte <fotte@uni-osnabrueck.de>
Subject: [PATCH] mci: avoid out of bounds partition access
Date: Tue, 3 Sep 2024 13:34:33 +0200 [thread overview]
Message-ID: <20240903113433.3512146-1-s.hauer@pengutronix.de> (raw)
The mci->part array has MMC_NUM_PHY_PARTITION. Avoid creating more
partitions than we have entries in the array and print an error
message instead.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Florian Otte <fotte@uni-osnabrueck.de>
---
drivers/mci/mci-core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 0261f36d89..ec4a5c0749 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -651,7 +651,15 @@ static void mci_part_add(struct mci *mci, uint64_t size,
unsigned int part_cfg, char *name, char *partname, int idx, bool ro,
int area_type)
{
- struct mci_part *part = &mci->part[mci->nr_parts];
+ struct mci_part *part;
+
+ if (mci->nr_parts == MMC_NUM_PHY_PARTITION) {
+ dev_err(&mci->dev, "Out of physical partitions, cannot create partition %s\n",
+ name);
+ return;
+ }
+
+ part = &mci->part[mci->nr_parts];
part->mci = mci;
part->size = size;
--
2.39.2
next reply other threads:[~2024-09-03 11:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 11:34 Sascha Hauer [this message]
2024-09-05 13:19 ` Sascha Hauer
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=20240903113433.3512146-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=fotte@uni-osnabrueck.de \
/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