btrfs-progs: clear_extent_bits: Fix memory leak.
authorchandan <chandan@linux.vnet.ibm.com>
Fri, 20 Sep 2013 18:22:11 +0000 (23:52 +0530)
committerChris Mason <chris.mason@fusionio.com>
Wed, 16 Oct 2013 12:23:11 +0000 (08:23 -0400)
The 'prealloc' extent_state structure is leaked for the case when the 'desired
range' encapsulates/covers the 'extent range'.

Signed-off-by: chandan <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
extent_io.c

index acc4702..1c481d5 100644 (file)
@@ -210,9 +210,11 @@ int clear_extent_bits(struct extent_io_tree *tree, u64 start,
        int set = 0;
 
 again:
-       prealloc = alloc_extent_state();
-       if (!prealloc)
-               return -ENOMEM;
+       if (!prealloc) {
+               prealloc = alloc_extent_state();
+               if (!prealloc)
+                       return -ENOMEM;
+       }
 
        /*
         * this search will find the extents that end after