* [PATCH] mci: avoid out of bounds partition access
@ 2024-09-03 11:34 Sascha Hauer
2024-09-05 13:19 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2024-09-03 11:34 UTC (permalink / raw)
To: Barebox List; +Cc: Florian Otte
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-05 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-03 11:34 [PATCH] mci: avoid out of bounds partition access Sascha Hauer
2024-09-05 13:19 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox