Print this page
9637 Memleak in pcibus.so`pci_slot_label_lookup.
*** 219,229 ****
char *
pci_slot_label_lookup(topo_mod_t *mod, tnode_t *node, did_t *dp, did_t *pdp)
{
tnode_t *anode, *apnode;
did_t *adp, *apdp;
! char *plat, *pp, *l, *ancestor_l = NULL, *new_l = NULL;
int err, b, d, f, done = 0;
size_t len;
did_BDF(dp, &b, &d, &f);
--- 219,229 ----
char *
pci_slot_label_lookup(topo_mod_t *mod, tnode_t *node, did_t *dp, did_t *pdp)
{
tnode_t *anode, *apnode;
did_t *adp, *apdp;
! char *plat, *pp, *l = NULL, *ancestor_l = NULL, *new_l = NULL;
int err, b, d, f, done = 0;
size_t len;
did_BDF(dp, &b, &d, &f);
*** 350,369 ****
__func__, node, ancestor_l, l);
len = strlen(ancestor_l) + strlen(l) + 2;
new_l = alloca(len);
(void) snprintf(new_l, len, "%s/%s", ancestor_l, l);
l = new_l;
! } else {
/*
- * Get platform name used for lookups.
- */
- if (topo_prop_get_string(node, FM_FMRI_AUTHORITY,
- FM_FMRI_AUTH_PRODUCT, &plat, &err) < 0) {
- (void) topo_mod_seterrno(mod, err);
- return (NULL);
- }
- /*
* Trim SUNW, from the platform name
*/
pp = strchr(plat, ',');
if (pp == NULL)
pp = plat;
--- 350,362 ----
__func__, node, ancestor_l, l);
len = strlen(ancestor_l) + strlen(l) + 2;
new_l = alloca(len);
(void) snprintf(new_l, len, "%s/%s", ancestor_l, l);
l = new_l;
! } else if (topo_prop_get_string(node, FM_FMRI_AUTHORITY,
! FM_FMRI_AUTH_PRODUCT, &plat, &err) == 0) {
/*
* Trim SUNW, from the platform name
*/
pp = strchr(plat, ',');
if (pp == NULL)
pp = plat;
*** 394,405 ****
--- 387,403 ----
l = (char *)
pci_label_missing_lookup(mod, pp, dp);
}
}
topo_mod_strfree(mod, plat);
+ } else {
+ (void) topo_mod_seterrno(mod, err);
+ l = NULL;
}
+ topo_mod_strfree(mod, ancestor_l);
+
/*
* If we calculated a slot label, then save it in the
* node's data structure so we can free it later.
*/
if (l) {