text-based mount.nfs: Fix memory leak in add_mtab()
authorChuck Lever <chuck.lever@oracle.com>
Mon, 24 Sep 2007 15:28:44 +0000 (11:28 -0400)
committerNeil Brown <neilb@suse.de>
Tue, 25 Sep 2007 01:50:15 +0000 (11:50 +1000)
The add_mtab() function in utils/mount/mount.c calls fix_opts_string() to
construct an /etc/mtab entry, but never frees the result.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Neil Brown <neilb@suse.de>
utils/mount/mount.c

index 751fbb9..31e1969 100644 (file)
@@ -237,6 +237,7 @@ static int add_mtab(char *spec, char *mount_point, char *fstype,
 
        if (flags & MS_REMOUNT) {
                update_mtab(ment.mnt_dir, &ment);
+               free(ment.mnt_opts);
                return EX_SUCCESS;
        }
 
@@ -267,6 +268,7 @@ fail_close:
        endmntent(mtab);
 fail_unlock:
        unlock_mtab();
+       free(ment.mnt_opts);
 
        return result;
 }