Skip to content

Commit 02f8fe4

Browse files
Josef 'Jeff' Sipekbehlendorf
authored andcommitted
Illumos 4626 - libzfs memleak in zpool_in_use()
4626 libzfs memleak in zpool_in_use() Reviewed by: Tony Nguyen <tony.nguyen@nexenta.com> Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com> Reviewed by: George Wilson <george.wilson@delphix.com> Approved by: Dan McDonald <danmcd@omniti.com> References: illumos/illumos-gate@fb13f48 https://www.illumos.org/issues/4626 Ported-by: kernelOfTruth kerneloftruth@gmail.com Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3563
1 parent cc49250 commit 02f8fe4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/libzfs/libzfs_import.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
/*
2222
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23-
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
2423
* Copyright (c) 2012 by Delphix. All rights reserved.
24+
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
2525
*/
2626

2727
/*
@@ -1532,9 +1532,16 @@ zpool_in_use(libzfs_handle_t *hdl, int fd, pool_state_t *state, char **namestr,
15321532
* its state to active.
15331533
*/
15341534
if (pool_active(hdl, name, guid, &isactive) == 0 && isactive &&
1535-
(zhp = zpool_open_canfail(hdl, name)) != NULL &&
1536-
zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL))
1537-
stateval = POOL_STATE_ACTIVE;
1535+
(zhp = zpool_open_canfail(hdl, name)) != NULL) {
1536+
if (zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL))
1537+
stateval = POOL_STATE_ACTIVE;
1538+
1539+
/*
1540+
* All we needed the zpool handle for is the
1541+
* readonly prop check.
1542+
*/
1543+
zpool_close(zhp);
1544+
}
15381545

15391546
ret = B_TRUE;
15401547
break;

0 commit comments

Comments
 (0)