diff options
author | Alan Somers <asomers@FreeBSD.org> | 2017-09-25 20:44:40 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2017-09-25 20:44:40 +0000 |
commit | 76f9ab74446d311d8afcad9fd1d0eec2143ba0ac (patch) | |
tree | 50de6f16d5ed8f3cb671bd624edf9c3f11bcd2a1 /cddl/usr.sbin | |
parent | 09f3bb8756067546a04511c48cf3aea6ce743ee1 (diff) | |
download | src-76f9ab74446d311d8afcad9fd1d0eec2143ba0ac.tar.gz src-76f9ab74446d311d8afcad9fd1d0eec2143ba0ac.zip |
Close a memory leak when using zpool_read_all_labels
MFC after: 3 weeks
X-MFC-With: 322854
Sponsored by: Spectra Logic Corp
Notes
Notes:
svn path=/head/; revision=323995
Diffstat (limited to 'cddl/usr.sbin')
-rw-r--r-- | cddl/usr.sbin/zfsd/zfsd_event.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cddl/usr.sbin/zfsd/zfsd_event.cc b/cddl/usr.sbin/zfsd/zfsd_event.cc index 706b1b1ed2ba..5594b35a88a8 100644 --- a/cddl/usr.sbin/zfsd/zfsd_event.cc +++ b/cddl/usr.sbin/zfsd/zfsd_event.cc @@ -101,7 +101,7 @@ DevfsEvent::ReadLabel(int devFd, bool &inUse, bool °raded) 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 °raded) * 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 °raded) exp.GetString().insert(0, context); exp.Log(); + nvlist_free(devLabel); } } return (NULL); |