Btrfs: fix memory leak of chunks' extent map
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / volumes.c
index 8bffb9174afba04d8375b96f754256b68ff9b4ef..b6c23c4abae273f09575b96f72fe3b98823d1a45 100644 (file)
@@ -4248,6 +4248,7 @@ int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
                btrfs_emerg(fs_info, "Invalid mapping for %Lu-%Lu, got "
                            "%Lu-%Lu\n", logical, logical+len, em->start,
                            em->start + em->len);
+               free_extent_map(em);
                return 1;
        }
 
@@ -4429,6 +4430,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
                btrfs_crit(fs_info, "found a bad mapping, wanted %Lu, "
                           "found %Lu-%Lu\n", logical, em->start,
                           em->start + em->len);
+               free_extent_map(em);
                return -EINVAL;
        }