Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2017 20:44:41 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323995 - head/cddl/usr.sbin/zfsd
Message-ID:  <201709252044.v8PKifx5047069@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Mon Sep 25 20:44:40 2017
New Revision: 323995
URL: https://svnweb.freebsd.org/changeset/base/323995

Log:
  Close a memory leak when using zpool_read_all_labels
  
  MFC after:	3 weeks
  X-MFC-With:	322854
  Sponsored by:	Spectra Logic Corp

Modified:
  head/cddl/usr.sbin/zfsd/zfsd_event.cc

Modified: head/cddl/usr.sbin/zfsd/zfsd_event.cc
==============================================================================
--- head/cddl/usr.sbin/zfsd/zfsd_event.cc	Mon Sep 25 20:38:55 2017	(r323994)
+++ head/cddl/usr.sbin/zfsd/zfsd_event.cc	Mon Sep 25 20:44:40 2017	(r323995)
@@ -101,7 +101,7 @@ DevfsEvent::ReadLabel(int devFd, bool &inUse, bool &de
 	poolName = NULL;
 	if (zpool_in_use(g_zfsHandle, devFd, &poolState,
 			 &poolName, &b_inuse) == 0) {
-		nvlist_t *devLabel;
+		nvlist_t *devLabel = NULL;
 
 		inUse = b_inuse == B_TRUE;
 		if (poolName != NULL)
@@ -116,8 +116,10 @@ DevfsEvent::ReadLabel(int devFd, bool &inUse, bool &de
 		 * might be damaged.  In that case, zfsd should do nothing and
 		 * wait for the sysadmin to decide.
 		 */
-		if (nlabels != VDEV_LABELS || devLabel == NULL)
+		if (nlabels != VDEV_LABELS || devLabel == NULL) {
+			nvlist_free(devLabel);
 			return (NULL);
+		}
 
 		try {
 			Vdev vdev(devLabel);
@@ -131,6 +133,7 @@ DevfsEvent::ReadLabel(int devFd, bool &inUse, bool &de
 
 			exp.GetString().insert(0, context);
 			exp.Log();
+			nvlist_free(devLabel);
 		}
 	}
 	return (NULL);



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