summaryrefslogtreecommitdiff
path: root/misc/fsck.c
diff options
context:
space:
mode:
authorBrian Behlendorf <behlendorf1@llnl.gov>2007-03-28 09:48:07 -0400
committerTheodore Ts'o <tytso@mit.edu>2007-03-28 09:48:07 -0400
commit12f8ff440cbea083797a3f62fe8c8ab0e03f2e6b (patch)
treeef7474b5f8ea7eb65738cfe4f9ad4bcae3861a63 /misc/fsck.c
parent0bed54fd3ea86772022fa994a6af265613464699 (diff)
downloade2fsprogs-12f8ff440cbea083797a3f62fe8c8ab0e03f2e6b.tar.gz
[COVERITY] Fix memory leak in fsck on error paths
The memory allocated by inst is not reclaimed. There also was a call to exit that coverity did not catch the resource leak. This might not really be a big issue since the memory will be freed when fsck exits, but it should be done anyway imho. Coverity ID: 32: Resource Leak Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Diffstat (limited to 'misc/fsck.c')
-rw-r--r--misc/fsck.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/misc/fsck.c b/misc/fsck.c
index 06ee02b3..1dcac259 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -470,6 +470,7 @@ static int execute(const char *type, const char *device, const char *mntpt,
s = find_fsck(prog);
if (s == NULL) {
fprintf(stderr, _("fsck: %s: not found\n"), prog);
+ free(inst);
return ENOENT;
}
@@ -486,12 +487,14 @@ static int execute(const char *type, const char *device, const char *mntpt,
pid = -1;
else if ((pid = fork()) < 0) {
perror("fork");
+ free(inst);
return errno;
} else if (pid == 0) {
if (!interactive)
close(0);
(void) execv(s, argv);
perror(argv[0]);
+ free(inst);
exit(EXIT_ERROR);
}