From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] mtd: don't try to detect UBI in too small flash partitions
Date: Wed, 28 Feb 2024 17:03:04 +0100 [thread overview]
Message-ID: <20240228160304.1588645-1-a.fatoum@pengutronix.de> (raw)
The detect callback will try to detect an UBI volume inside a partition.
If that partition happens to be smaller than 512 bytes, detect will fail
with -EINVAL.
Avoid this confusing error by early exiting in this case.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/mtd/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 97a7996cf68e..34f919b96ea4 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -599,6 +599,10 @@ static int mtd_detect(struct device *dev)
enum filetype filetype;
int npebs = mtd_div_by_eb(mtd->size, mtd);
+ /* No point in looking for UBI on a partition that's smaller than an erase block */
+ if (!npebs)
+ return 0;
+
npebs = max(npebs, 64);
/*
--
2.39.2
next reply other threads:[~2024-02-28 16:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 16:03 Ahmad Fatoum [this message]
2024-02-29 7:42 ` 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=20240228160304.1588645-1-a.fatoum@pengutronix.de \
--to=a.fatoum@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