]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
[COVERITY] Fix memory leak in fsck on error paths
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 28 Mar 2007 13:48:07 +0000 (09:48 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 28 Mar 2007 13:48:07 +0000 (09:48 -0400)
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>
misc/ChangeLog
misc/fsck.c

index 8341d4721aab3a6052780a2da30244712baa8099..bf7a8c8519fd07025d8fe8a262b585d72ff82fdb 100644 (file)
@@ -1,3 +1,7 @@
+2007-03-28  Theodore Tso  <tytso@mit.edu>
+
+       * fsck.c (execute): Fix memory leak on error paths
+
 2007-03-21  Theodore Tso  <tytso@mit.edu>
 
        * e2image.c (output_meta_data_blocks, write_raw_image_file): Fix
index 06ee02b30adea60c3935e9870bc27807f625a2af..1dcac259954db26cfee852cf68c0cdd7800af8aa 100644 (file)
@@ -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);
        }