]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ubi: correct the calculation of fastmap size
authorZhang Yi <yi.zhang@huawei.com>
Tue, 20 Feb 2024 02:49:03 +0000 (10:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 10:58:10 +0000 (12:58 +0200)
[ Upstream commit 7f174ae4f39e8475adcc09d26c5a43394689ad6c ]

Now that the calculation of fastmap size in ubi_calc_fm_size() is
incorrect since it miss each user volume's ubi_fm_eba structure and the
Internal UBI volume info. Let's correct the calculation.

Cc: stable@vger.kernel.org
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/ubi/fastmap.c

index 6e95c4b1473e61e85c86068b4547ce765777626c..8081fc760d34f054af6987f6947d71f4b4a7d837 100644 (file)
@@ -86,9 +86,10 @@ size_t ubi_calc_fm_size(struct ubi_device *ubi)
                sizeof(struct ubi_fm_scan_pool) +
                sizeof(struct ubi_fm_scan_pool) +
                (ubi->peb_count * sizeof(struct ubi_fm_ec)) +
-               (sizeof(struct ubi_fm_eba) +
-               (ubi->peb_count * sizeof(__be32))) +
-               sizeof(struct ubi_fm_volhdr) * UBI_MAX_VOLUMES;
+               ((sizeof(struct ubi_fm_eba) +
+                 sizeof(struct ubi_fm_volhdr)) *
+                (UBI_MAX_VOLUMES + UBI_INT_VOL_COUNT)) +
+               (ubi->peb_count * sizeof(__be32));
        return roundup(size, ubi->leb_size);
 }