Message ID | 20231026153508.6845-2-yuxuan.luo@canonical.com |
---|---|
State | New |
Headers | show |
Series | CVE-2023-31085 | expand |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index f29ed9102ce91..a7169b0d5ba65 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -865,6 +865,13 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, return -EINVAL; } + /* UBI cannot work on flashes with zero erasesize. */ + if (!mtd->erasesize) { + pr_err("ubi: refuse attaching mtd%d - zero erasesize flash is not supported\n", + mtd->index); + return -EINVAL; + } + if (ubi_num == UBI_DEV_NUM_AUTO) { /* Search for an empty slot in the @ubi_devices array */ for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++)