Print this page
4626 libzfs memleak in zpool_in_use()
Reviewed by: Tony Nguyen <tony.nguyen@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_import.c
          +++ new/usr/src/lib/libzfs/common/libzfs_import.c
↓ open down ↓ 1560 lines elided ↑ open up ↑
1561 1561  
1562 1562          switch (stateval) {
1563 1563          case POOL_STATE_EXPORTED:
1564 1564                  /*
1565 1565                   * A pool with an exported state may in fact be imported
1566 1566                   * read-only, so check the in-core state to see if it's
1567 1567                   * active and imported read-only.  If it is, set
1568 1568                   * its state to active.
1569 1569                   */
1570 1570                  if (pool_active(hdl, name, guid, &isactive) == 0 && isactive &&
1571      -                    (zhp = zpool_open_canfail(hdl, name)) != NULL &&
1572      -                    zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL))
1573      -                        stateval = POOL_STATE_ACTIVE;
     1571 +                    (zhp = zpool_open_canfail(hdl, name)) != NULL) {
     1572 +                        if (zpool_get_prop_int(zhp, ZPOOL_PROP_READONLY, NULL))
     1573 +                                stateval = POOL_STATE_ACTIVE;
     1574 +
     1575 +                        zpool_close(zhp);
     1576 +                }
1574 1577  
1575 1578                  ret = B_TRUE;
1576 1579                  break;
1577 1580  
1578 1581          case POOL_STATE_ACTIVE:
1579 1582                  /*
1580 1583                   * For an active pool, we have to determine if it's really part
1581 1584                   * of a currently active pool (in which case the pool will exist
1582 1585                   * and the guid will be the same), or whether it's part of an
1583 1586                   * active pool that was disconnected without being explicitly
↓ open down ↓ 108 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX