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@xxxxxxxxxxxxxx> --- 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