Print this page
6659 nvlist_free(NULL) is a no-op


8012                 cphci->cphci_id = phci_count++;
8013 
8014         /* build phci pathname list */
8015         phcis = kmem_alloc(sizeof (char *) * phci_count, KM_SLEEP);
8016         for (cphci = vhcache->vhcache_phci_head, i = 0; cphci != NULL;
8017             cphci = cphci->cphci_next, i++)
8018                 phcis[i] = i_ddi_strdup(cphci->cphci_path, KM_SLEEP);
8019 
8020         err = nvlist_add_string_array(nvl, MDI_NVPNAME_PHCIS, phcis,
8021             phci_count);
8022         free_string_array(phcis, phci_count);
8023 
8024         if (err == 0 &&
8025             (err = vhcache_to_caddrmapnvl(vhcache, nvl)) == 0) {
8026                 rw_exit(&vhcache->vhcache_lock);
8027                 return (nvl);
8028         }
8029 
8030         rw_exit(&vhcache->vhcache_lock);
8031 out:
8032         if (nvl)
8033                 nvlist_free(nvl);
8034         return (NULL);
8035 }
8036 
8037 /*
8038  * Lookup vhcache phci structure for the specified phci path.
8039  */
8040 static mdi_vhcache_phci_t *
8041 lookup_vhcache_phci_by_name(mdi_vhci_cache_t *vhcache, char *phci_path)
8042 {
8043         mdi_vhcache_phci_t *cphci;
8044 
8045         ASSERT(RW_LOCK_HELD(&vhcache->vhcache_lock));
8046 
8047         for (cphci = vhcache->vhcache_phci_head; cphci != NULL;
8048             cphci = cphci->cphci_next) {
8049                 if (strcmp(cphci->cphci_path, phci_path) == 0)
8050                         return (cphci);
8051         }
8052 




8012                 cphci->cphci_id = phci_count++;
8013 
8014         /* build phci pathname list */
8015         phcis = kmem_alloc(sizeof (char *) * phci_count, KM_SLEEP);
8016         for (cphci = vhcache->vhcache_phci_head, i = 0; cphci != NULL;
8017             cphci = cphci->cphci_next, i++)
8018                 phcis[i] = i_ddi_strdup(cphci->cphci_path, KM_SLEEP);
8019 
8020         err = nvlist_add_string_array(nvl, MDI_NVPNAME_PHCIS, phcis,
8021             phci_count);
8022         free_string_array(phcis, phci_count);
8023 
8024         if (err == 0 &&
8025             (err = vhcache_to_caddrmapnvl(vhcache, nvl)) == 0) {
8026                 rw_exit(&vhcache->vhcache_lock);
8027                 return (nvl);
8028         }
8029 
8030         rw_exit(&vhcache->vhcache_lock);
8031 out:

8032         nvlist_free(nvl);
8033         return (NULL);
8034 }
8035 
8036 /*
8037  * Lookup vhcache phci structure for the specified phci path.
8038  */
8039 static mdi_vhcache_phci_t *
8040 lookup_vhcache_phci_by_name(mdi_vhci_cache_t *vhcache, char *phci_path)
8041 {
8042         mdi_vhcache_phci_t *cphci;
8043 
8044         ASSERT(RW_LOCK_HELD(&vhcache->vhcache_lock));
8045 
8046         for (cphci = vhcache->vhcache_phci_head; cphci != NULL;
8047             cphci = cphci->cphci_next) {
8048                 if (strcmp(cphci->cphci_path, phci_path) == 0)
8049                         return (cphci);
8050         }
8051