aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoropeneuler-ci-bot <george@openeuler.sh>2024-04-25 12:49:55 +0000
committerGitee <noreply@gitee.com>2024-04-25 12:49:55 +0000
commit971d7499eabea5b0ce2b3b7068cffd5036e0aa27 (patch)
tree322b34c9b705bdc4f7fc6c9f8d3afb520d9fb638
parentac8157923d90b9847ea20026f0cb17f4959874f8 (diff)
parent81796028fe868cdacd8b1a34d56e43b3ba781b6b (diff)
downloadopenEuler-kernel-971d7499eabea5b0ce2b3b7068cffd5036e0aa27.tar.gz
!6250 ubi: Check for too small LEB size in VTBL code
Merge Pull Request from: @ci-robot PR sync from: ZhaoLong Wang <wangzhaolong1@huawei.com> https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/YJWGA7NUV7TABITXWZSCQMEMSU4UN6FI/ https://gitee.com/src-openeuler/kernel/issues/I91L79 Link:https://gitee.com/openeuler/kernel/pulls/6250 Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com>
-rw-r--r--drivers/mtd/ubi/vtbl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index f700f0e4f2ec4d..6e5489e233dd2a 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -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;