close fd if open, and free allocated memory in buf
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
int do_rollback(const char *devname, int force)
{
- int fd;
+ int fd = -1;
int ret;
int i;
struct btrfs_root *root;
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;
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;
}