summaryrefslogtreecommitdiffstats
path: root/kernel/drivers/mtd/ubi/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/mtd/ubi/io.c')
-rw-r--r--kernel/drivers/mtd/ubi/io.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/drivers/mtd/ubi/io.c b/kernel/drivers/mtd/ubi/io.c
index 5bbd1f094..10cf3b549 100644
--- a/kernel/drivers/mtd/ubi/io.c
+++ b/kernel/drivers/mtd/ubi/io.c
@@ -926,6 +926,11 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
goto bad;
}
+ if (data_size > ubi->leb_size) {
+ ubi_err(ubi, "bad data_size");
+ goto bad;
+ }
+
if (vol_type == UBI_VID_STATIC) {
/*
* Although from high-level point of view static volumes may
@@ -1294,7 +1299,7 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err))
goto exit;
- crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC);
+ crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC);
hdr_crc = be32_to_cpu(vid_hdr->hdr_crc);
if (hdr_crc != crc) {
ubi_err(ubi, "bad VID header CRC at PEB %d, calculated %#08x, read %#08x",