Unverified Commit bfaa0cba authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!6247 ubi: Check for too small LEB size in VTBL code

parents 379c369c 0b890629
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -791,6 +791,12 @@ 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.
	 */

	if (ubi->leb_size < UBI_VTBL_RECORD_SIZE) {
		ubi_err(ubi, "LEB size too small for a volume record");
		return -EINVAL;
	}

	ubi->vtbl_slots = ubi->leb_size / UBI_VTBL_RECORD_SIZE;
	if (ubi->vtbl_slots > UBI_MAX_VOLUMES)
		ubi->vtbl_slots = UBI_MAX_VOLUMES;