UBI: Fastmap: Calc fastmap size correctly
[sfrench/cifs-2.6.git] / drivers / mtd / ubi / fastmap.c
index 0431b46d9fd9e0211a8c7f5e865721a6b32895b5..cfd5b5e90156e536ca9cd479286248bb7dadc8e6 100644 (file)
@@ -24,7 +24,8 @@ size_t ubi_calc_fm_size(struct ubi_device *ubi)
 {
        size_t size;
 
-       size = sizeof(struct ubi_fm_hdr) + \
+       size = sizeof(struct ubi_fm_sb) + \
+               sizeof(struct ubi_fm_hdr) + \
                sizeof(struct ubi_fm_scan_pool) + \
                sizeof(struct ubi_fm_scan_pool) + \
                (ubi->peb_count * sizeof(struct ubi_fm_ec)) + \
@@ -330,6 +331,7 @@ static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai,
                av = tmp_av;
        else {
                ubi_err("orphaned volume in fastmap pool!");
+               kmem_cache_free(ai->aeb_slab_cache, new_aeb);
                return UBI_BAD_FASTMAP;
        }