diff options
author | Eric Sandeen <sandeen@redhat.com> | 2013-03-04 16:39:53 -0600 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-03-10 15:49:07 +0100 |
commit | c74beb90eaf2ddedfcabc35cf81bac580f5aa9b6 (patch) | |
tree | 2173119ed5cc9f33d52b84980fac592399a1cba7 | |
parent | 9e769c4864234a22d2e01a0a1cf7d3bac2db8b5c (diff) |
btrfs-progs: free resources on do_rollback error returns
close fd if open, and free allocated memory in buf
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
-rw-r--r-- | convert.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -2455,7 +2455,7 @@ fail: int do_rollback(const char *devname, int force) { - int fd; + int fd = -1; int ret; int i; struct btrfs_root *root; @@ -2471,7 +2471,7 @@ int do_rollback(const char *devname, int force) struct btrfs_key key; struct btrfs_path path; struct extent_io_tree io_tree; - char *buf; + char *buf = NULL; char *name; u64 bytenr; u64 num_bytes; @@ -2751,7 +2751,11 @@ next_sector: extent_io_tree_cleanup(&io_tree); printf("rollback complete.\n"); return 0; + fail: + if (fd != -1) + close(fd); + free(buf); fprintf(stderr, "rollback aborted.\n"); return -1; } |