diff options
author | Stefan Behrens <sbehrens@giantdisaster.de> | 2013-04-23 11:25:00 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2013-04-23 19:12:03 +0200 |
commit | 576bcca973567e6af8337d4f9f0d8703a83c556b (patch) | |
tree | 6eef3a2e8acf70666e88ca3428d77cf18c2d562e /cmds-send.c | |
parent | b0d43ad859afbc708fafaa47197fb746400e4eaa (diff) |
Btrfs-progs: btrfs-send: free used memory and close fds
Not important at all since exit() is called afterwards and this is
not part of the library. It just makes valgrind happy and thus
allows to search for real flaws.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Diffstat (limited to 'cmds-send.c')
-rw-r--r-- | cmds-send.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cmds-send.c b/cmds-send.c index 9bb4206a..0057e6b8 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -467,6 +467,13 @@ int cmd_send_start(int argc, char **argv) add_clone_source(&send, root_id); subvol_uuid_search_finit(&send.sus); free(subvol); + subvol = NULL; + if (send.mnt_fd >= 0) { + close(send.mnt_fd); + send.mnt_fd = -1; + } + free(send.root_path); + send.root_path = NULL; full_send = 0; break; case 'f': @@ -475,7 +482,8 @@ int cmd_send_start(int argc, char **argv) case 'p': if (snapshot_parent) { fprintf(stderr, "ERROR: you cannot have more than one parent (-p)\n"); - return 1; + ret = 1; + goto out; } snapshot_parent = realpath(optarg, NULL); if (!snapshot_parent) { @@ -489,17 +497,20 @@ int cmd_send_start(int argc, char **argv) case 'i': fprintf(stderr, "ERROR: -i was removed, use -c instead\n"); - return 1; + ret = 1; + goto out; case '?': default: fprintf(stderr, "ERROR: send args invalid.\n"); - return 1; + ret = 1; + goto out; } } if (optind == argc) { fprintf(stderr, "ERROR: send needs path to snapshot\n"); - return 1; + ret = 1; + goto out; } if (outname != NULL) { @@ -516,7 +527,8 @@ int cmd_send_start(int argc, char **argv) fprintf(stderr, "ERROR: not dumping send stream into a terminal, " "redirect it into a file\n"); - return 1; + ret = 1; + goto out; } /* use first send subvol to determine mount_root */ @@ -547,6 +559,7 @@ int cmd_send_start(int argc, char **argv) } for (i = optind; i < argc; i++) { + free(subvol); subvol = realpath(argv[i], NULL); if (!subvol) { ret = -errno; @@ -578,10 +591,10 @@ int cmd_send_start(int argc, char **argv) subvol); goto out; } - free(subvol); } for (i = optind; i < argc; i++) { + free(subvol); subvol = argv[i]; fprintf(stderr, "At subvol %s\n", subvol); @@ -630,14 +643,17 @@ int cmd_send_start(int argc, char **argv) parent_root_id = 0; full_send = 0; - free(subvol); } ret = 0; out: + free(subvol); + free(snapshot_parent); + free(send.clone_sources); if (send.mnt_fd >= 0) close(send.mnt_fd); + free(send.root_path); subvol_uuid_search_finit(&send.sus); return ret; } |