diff options
author | Josef 'Jeff' Sipek <[email protected]> | 2015-07-05 01:54:29 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-07-10 11:57:38 -0700 |
commit | 02f8fe42606c6d7657a7dace24c8efc9b245e500 (patch) | |
tree | 77b41c85bb31e8502aee694fb00b4c731f7c9552 | |
parent | cc49250563b65c80d87afa5273ae350d06aa8d3b (diff) |
Illumos 4626 - libzfs memleak in zpool_in_use()
4626 libzfs memleak in zpool_in_use()
Reviewed by: Tony Nguyen <[email protected]>
Reviewed by: Saso Kiselkov <[email protected]>
Reviewed by: George Wilson <[email protected]>
Approved by: Dan McDonald <[email protected]>
References:
https://github.com/illumos/illumos-gate/commit/fb13f48
https://www.illumos.org/issues/4626
Ported-by: kernelOfTruth [email protected]
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3563
-rw-r--r-- | lib/libzfs/libzfs_import.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 182168456..5dc1482d7 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -20,8 +20,8 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. */ /* @@ -1532,9 +1532,16 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr, * its state to active. */ if (pool_active(hdl, name, guid, &isactive) == 0 && isactive && - (zhp = zpool_open_canfail(hdl, name)) != NULL && - zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL)) - stateval = POOL_STATE_ACTIVE; + (zhp = zpool_open_canfail(hdl, name)) != NULL) { + if (zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL)) + stateval = POOL_STATE_ACTIVE; + + /* + * All we needed the zpool handle for is the + * readonly prop check. + */ + zpool_close(zhp); + } ret = B_TRUE; break; |