aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliuhuang <[email protected]>2016-09-11 04:41:19 +0800
committerBrian Behlendorf <[email protected]>2016-09-12 09:44:26 -0700
commitbd296705d5b6a8d3fb03d93cb2e341ea04c3809f (patch)
tree4f46fe9b69216ace24262e53c095cd115c4d261b
parent89f67518e1c25a586ba2663210ec9791f12f1fba (diff)
Fix memory/fd leak in check_file() and is_spare()
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: liuhuang <[email protected]> Closes #5085
-rw-r--r--cmd/zpool/zpool_vdev.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/zpool/zpool_vdev.c b/cmd/zpool/zpool_vdev.c
index 7ad44a948..7d114889f 100644
--- a/cmd/zpool/zpool_vdev.c
+++ b/cmd/zpool/zpool_vdev.c
@@ -334,8 +334,11 @@ check_file(const char *file, boolean_t force, boolean_t isspare)
/*
* Allow hot spares to be shared between pools.
*/
- if (state == POOL_STATE_SPARE && isspare)
+ if (state == POOL_STATE_SPARE && isspare) {
+ free(name);
+ (void) close(fd);
return (0);
+ }
if (state == POOL_STATE_ACTIVE ||
state == POOL_STATE_SPARE || !force) {
@@ -583,8 +586,10 @@ is_spare(nvlist_t *config, const char *path)
free(name);
(void) close(fd);
- if (config == NULL)
+ if (config == NULL) {
+ nvlist_free(label);
return (B_TRUE);
+ }
verify(nvlist_lookup_uint64(label, ZPOOL_CONFIG_GUID, &guid) == 0);
nvlist_free(label);