mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-07 01:31:17 +00:00
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>
This commit is contained in:
parent
9e769c4864
commit
c74beb90ea
@ -2455,7 +2455,7 @@ fail:
|
|||||||
|
|
||||||
int do_rollback(const char *devname, int force)
|
int do_rollback(const char *devname, int force)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd = -1;
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
struct btrfs_root *root;
|
struct btrfs_root *root;
|
||||||
@ -2471,7 +2471,7 @@ int do_rollback(const char *devname, int force)
|
|||||||
struct btrfs_key key;
|
struct btrfs_key key;
|
||||||
struct btrfs_path path;
|
struct btrfs_path path;
|
||||||
struct extent_io_tree io_tree;
|
struct extent_io_tree io_tree;
|
||||||
char *buf;
|
char *buf = NULL;
|
||||||
char *name;
|
char *name;
|
||||||
u64 bytenr;
|
u64 bytenr;
|
||||||
u64 num_bytes;
|
u64 num_bytes;
|
||||||
@ -2751,7 +2751,11 @@ next_sector:
|
|||||||
extent_io_tree_cleanup(&io_tree);
|
extent_io_tree_cleanup(&io_tree);
|
||||||
printf("rollback complete.\n");
|
printf("rollback complete.\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
if (fd != -1)
|
||||||
|
close(fd);
|
||||||
|
free(buf);
|
||||||
fprintf(stderr, "rollback aborted.\n");
|
fprintf(stderr, "rollback aborted.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user