Btrfs-progs: fsck: fix memory leak and unnecessary call to free
authorRakesh Pandit <rakesh@tuxera.com>
Sat, 15 Mar 2014 12:22:37 +0000 (14:22 +0200)
committerChris Mason <clm@fb.com>
Fri, 21 Mar 2014 16:51:31 +0000 (09:51 -0700)
Free already allocated memory to item1_data if malloc fails for
item2_data in swap_values. Seems to be a typo from commit 70749a77.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
cmds-check.c

index d1cafe1..60708d0 100644 (file)
@@ -2380,7 +2380,7 @@ static int swap_values(struct btrfs_root *root, struct btrfs_path *path,
                        return -ENOMEM;
                item2_data = malloc(item2_size);
                if (!item2_data) {
-                       free(item2_data);
+                       free(item1_data);
                        return -ENOMEM;
                }