Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2012 03:48:45 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r243698 - stable/9/sbin/umount
Message-ID:  <201211300348.qAU3mjRQ010618@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Fri Nov 30 03:48:45 2012
New Revision: 243698
URL: http://svnweb.freebsd.org/changeset/base/243698

Log:
  MFC r243082:
  	Fix memory leak in umount.c
  
  PR:		bin/172553
  Approved by:	cperciva (implicit)

Modified:
  stable/9/sbin/umount/umount.c
Directory Properties:
  stable/9/sbin/umount/   (props changed)

Modified: stable/9/sbin/umount/umount.c
==============================================================================
--- stable/9/sbin/umount/umount.c	Fri Nov 30 03:38:02 2012	(r243697)
+++ stable/9/sbin/umount/umount.c	Fri Nov 30 03:48:45 2012	(r243698)
@@ -359,8 +359,10 @@ umountfs(struct statfs *sfs)
 			do_rpc = 1;
 	}
 
-	if (!namematch(ai))
+	if (!namematch(ai)) {
+		free(orignfsdirname);
 		return (1);
+	}
 	/* First try to unmount using the file system ID. */
 	snprintf(fsidbuf, sizeof(fsidbuf), "FSID:%d:%d", sfs->f_fsid.val[0],
 	    sfs->f_fsid.val[1]);
@@ -369,13 +371,16 @@ umountfs(struct statfs *sfs)
 		if (errno != ENOENT || sfs->f_fsid.val[0] != 0 ||
 		    sfs->f_fsid.val[1] != 0)
 			warn("unmount of %s failed", sfs->f_mntonname);
-		if (errno != ENOENT)
+		if (errno != ENOENT) {
+			free(orignfsdirname);
 			return (1);
+		}
 		/* Compatibility for old kernels. */
 		if (sfs->f_fsid.val[0] != 0 || sfs->f_fsid.val[1] != 0)
 			warnx("retrying using path instead of file system ID");
 		if (unmount(sfs->f_mntonname, fflag) != 0) {
 			warn("unmount of %s failed", sfs->f_mntonname);
+			free(orignfsdirname);
 			return (1);
 		}
 	}
@@ -393,6 +398,7 @@ umountfs(struct statfs *sfs)
 		if (clp  == NULL) {
 			warnx("%s: %s", hostp,
 			    clnt_spcreateerror("MOUNTPROG"));
+			free(orignfsdirname);
 			return (1);
 		}
 		clp->cl_auth = authsys_create_default();
@@ -403,6 +409,7 @@ umountfs(struct statfs *sfs)
 		if (clnt_stat != RPC_SUCCESS) {
 			warnx("%s: %s", hostp,
 			    clnt_sperror(clp, "RPCMNT_UMOUNT"));
+			free(orignfsdirname);
 			return (1);
 		}
 		/*
@@ -415,10 +422,10 @@ umountfs(struct statfs *sfs)
 				    hostp, nfsdirname);
 			free_mtab();
 		}
-		free(orignfsdirname);
 		auth_destroy(clp->cl_auth);
 		clnt_destroy(clp);
 	}
+	free(orignfsdirname);
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211300348.qAU3mjRQ010618>