ubi: Check the presence of volume before call ubi_fastmap_destroy_checkmap()
authorHou Tao <houtao1@huawei.com>
Sat, 30 Nov 2019 09:48:00 +0000 (17:48 +0800)
committerRichard Weinberger <richard@nod.at>
Thu, 16 Jan 2020 22:35:48 +0000 (23:35 +0100)
Else there may be oops when fastmap is enabled and init_volumes() fails.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/vtbl.c

index 53d8ab5..8a2a0f0 100644 (file)
@@ -852,6 +852,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
 out_free:
        vfree(ubi->vtbl);
        for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
+               if (!ubi->volumes[i])
+                       continue;
                ubi_fastmap_destroy_checkmap(ubi->volumes[i]);
                kfree(ubi->volumes[i]);
                ubi->volumes[i] = NULL;