diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index f700f0e4f2ec..e3b337afdb4f 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -791,7 +791,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) * The number of supported volumes is limited by the eraseblock size * and by the UBI_MAX_VOLUMES constant. */ - ubi->vtbl_slots = ubi->leb_size / UBI_VTBL_RECORD_SIZE; + ubi->vtbl_slots = ubi->leb_size > UBI_VTBL_RECORD_SIZE ? + ubi->leb_size / UBI_VTBL_RECORD_SIZE : 1; if (ubi->vtbl_slots > UBI_MAX_VOLUMES) ubi->vtbl_slots = UBI_MAX_VOLUMES;