Skip to content

Commit

Permalink
11158 fm: NULL pointer errors
Browse files Browse the repository at this point in the history
Reviewed by: John Levon <john.levon@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
  • Loading branch information
tsoome committed Jul 3, 2019
1 parent 5b8cbb8 commit 5cc5d5c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions usr/src/lib/fm/topo/modules/common/disk/disk_common.c
Expand Up @@ -143,7 +143,7 @@ disk_set_props(topo_mod_t *mod, tnode_t *parent,
nvlist_t *asru = NULL, *drive_attrs;
char *label = NULL;
nvlist_t *fmri = NULL;
dm_descriptor_t drive_descr = NULL;
dm_descriptor_t drive_descr = 0;
uint32_t rpm;
int err;

Expand Down Expand Up @@ -287,7 +287,7 @@ disk_set_props(topo_mod_t *mod, tnode_t *parent,

if (dnode->ddn_devid == NULL ||
(drive_descr = dm_get_descriptor_by_name(DM_DRIVE,
dnode->ddn_devid, &err)) == NULL ||
dnode->ddn_devid, &err)) == 0 ||
(drive_attrs = dm_get_attributes(drive_descr, &err)) == NULL)
goto out;

Expand All @@ -305,7 +305,7 @@ disk_set_props(topo_mod_t *mod, tnode_t *parent,
err = 0;

out:
if (drive_descr != NULL)
if (drive_descr != 0)
dm_free_descriptor(drive_descr);
nvlist_free(fmri);
if (label)
Expand Down Expand Up @@ -353,7 +353,7 @@ disk_temp_reading(topo_mod_t *mod, tnode_t *node, topo_version_t vers,
{
char *devid;
uint32_t temp;
dm_descriptor_t drive_descr = NULL;
dm_descriptor_t drive_descr = 0;
nvlist_t *drive_stats, *pargs, *nvl;
int err;

Expand All @@ -368,7 +368,7 @@ disk_temp_reading(topo_mod_t *mod, tnode_t *node, topo_version_t vers,
}

if ((drive_descr = dm_get_descriptor_by_name(DM_DRIVE, devid,
&err)) == NULL) {
&err)) == 0) {
topo_mod_dprintf(mod, "failed to get drive decriptor for %s",
devid);
return (topo_mod_seterrno(mod, EMOD_UNKNOWN));
Expand Down
12 changes: 6 additions & 6 deletions usr/src/lib/fm/topo/modules/common/ses/ses.c
Expand Up @@ -580,7 +580,7 @@ ses_contract_thread(void *arg)
(void) snprintf(buf, sizeof (buf),
"abandon old contract %d", stp->set_ctid);
ses_ct_print(buf);
stp->set_ctid = NULL;
stp->set_ctid = 0;
}
(void) ct_ctl_abandon(ctlfd);
}
Expand Down Expand Up @@ -702,7 +702,7 @@ ses_create_contract(topo_mod_t *mod, ses_enum_target_t *stp)
int tfd, len, rval;
char link_path[PATH_MAX];

stp->set_ctid = NULL;
stp->set_ctid = 0;

/* convert "/dev" path into "/devices" path */
if ((len = readlink(stp->set_devpath, link_path, PATH_MAX)) < 0) {
Expand Down Expand Up @@ -749,7 +749,7 @@ ses_target_free(topo_mod_t *mod, ses_enum_target_t *stp)
ctlfd = open64(path, O_WRONLY);
(void) ct_ctl_abandon(ctlfd);
(void) close(ctlfd);
stp->set_ctid = NULL;
stp->set_ctid = 0;
}
(void) pthread_mutex_unlock(&stp->set_lock);
ses_ssl_free(mod, stp);
Expand Down Expand Up @@ -939,7 +939,7 @@ ses_node_lock(topo_mod_t *mod, tnode_t *tn)
* contract (ie we've had the offline event but not yet the
* negend). If so, just return failure.
*/
if (tp->set_ctid != NULL) {
if (tp->set_ctid != 0) {
(void) topo_mod_seterrno(mod, EMOD_METHOD_NOTSUP);
(void) pthread_mutex_unlock(&tp->set_lock);
return (NULL);
Expand Down Expand Up @@ -1899,13 +1899,13 @@ ses_create_esc_sasspecific(ses_enum_data_t *sdp, ses_enum_node_t *snp,
topo_mod_t *mod = sdp->sed_mod;
tnode_t *exptn, *contn;
boolean_t found;
sas_connector_phy_data_t connectors[64] = {NULL};
sas_connector_phy_data_t connectors[64] = {0};
uint64_t max;
ses_enum_node_t *ctlsnp, *xsnp, *consnp;
ses_node_t *np = snp->sen_node;
nvlist_t *props, *psprops;
uint64_t index, psindex, conindex, psstatus, i, j, count;
int64_t cidxlist[256] = {NULL};
int64_t cidxlist[256] = {0};
int phycount;

props = ses_node_props(np);
Expand Down
6 changes: 3 additions & 3 deletions usr/src/lib/fm/topo/modules/common/smbios/smbios_enum.c
Expand Up @@ -153,7 +153,7 @@ smbios_make_slot(smb_enum_data_t *smed, smbios_memdevice_t *smb_md)
return (NULL);
}
if (topo_node_fru(smed->sme_pnode, &fmri, NULL, &err) != 0 ||
topo_node_fru_set(slotnode, fmri, NULL, &err) != 0) {
topo_node_fru_set(slotnode, fmri, 0, &err) != 0) {
topo_mod_dprintf(mod, "failed to set FRU on %s=%d: %s", SLOT,
smed->sme_slot_inst, topo_strerror(err));
nvlist_free(fmri);
Expand Down Expand Up @@ -262,7 +262,7 @@ smbios_make_dimm(smb_enum_data_t *smed, smbios_memdevice_t *smb_md)
topo_pgroup_hcset(dimmnode, auth);
nvlist_free(auth);

if (topo_node_fru_set(dimmnode, fmri, NULL, &err) != 0) {
if (topo_node_fru_set(dimmnode, fmri, 0, &err) != 0) {
topo_mod_dprintf(mod, "failed to set FRU on %s: %s",
DIMM, topo_strerror(err));
nvlist_free(fmri);
Expand Down Expand Up @@ -487,7 +487,7 @@ smbios_enum_motherboard(smbios_hdl_t *shp, smb_enum_data_t *smed)
topo_pgroup_hcset(mbnode, auth);
nvlist_free(auth);

if (topo_node_fru_set(mbnode, fmri, NULL, &err) != 0) {
if (topo_node_fru_set(mbnode, fmri, 0, &err) != 0) {
topo_mod_dprintf(mod, "failed to set FRU on %s: %s",
MOTHERBOARD, topo_strerror(err));
nvlist_free(fmri);
Expand Down
8 changes: 4 additions & 4 deletions usr/src/lib/fm/topo/modules/i86pc/chip/chip_intel.c
Expand Up @@ -429,7 +429,7 @@ mc_nb_create(topo_mod_t *mod, uint16_t chip_smbid, tnode_t *pnode,
}
}

return (NULL);
return (0);
}

int
Expand All @@ -451,7 +451,7 @@ mc_node_create(topo_mod_t *mod, uint16_t chip_smbid, tnode_t *pnode,

free(buf);
(void) close(mc_fd);
return (NULL);
return (0);
}
(void) close(mc_fd);
(void) nvlist_unpack(buf, mcs.mcs_size, &nvl, 0);
Expand All @@ -460,11 +460,11 @@ mc_node_create(topo_mod_t *mod, uint16_t chip_smbid, tnode_t *pnode,
if (nvlist_lookup_uint8(nvl, MCINTEL_NVLIST_VERSTR, &ver) != 0) {
whinge(mod, NULL, "mc nvlist is not versioned\n");
nvlist_free(nvl);
return (NULL);
return (0);
} else if (ver != MCINTEL_NVLIST_VERS0) {
whinge(mod, NULL, "mc nvlist version mismatch\n");
nvlist_free(nvl);
return (NULL);
return (0);
}

rc = mc_nb_create(mod, chip_smbid, pnode, name, auth, nvl);
Expand Down
4 changes: 2 additions & 2 deletions usr/src/lib/fm/topo/modules/i86pc/x86pi/x86pi_hostbridge.c
Expand Up @@ -106,7 +106,7 @@ pciex_process(topo_mod_t *mod, tnode_t *tn_hbr, di_node_t rcn,

if ((did = did_create(mod, rcn, topo_node_instance(tn_bb),
topo_node_instance(tn_hbr), rci, TRUST_BDF)) == NULL)
return (NULL);
return (-1);

did_markrc(did);

Expand Down Expand Up @@ -241,7 +241,7 @@ x86pi_gen_hbr(topo_mod_t *mod, tnode_t *tn_bb,
smbios_pciexrc_t smb_rc;
int i, rv, err = 0;
const char *f = "x86pi_gen_hbr";
smbios_hdl_t *shp;
smbios_hdl_t *shp;

shp = topo_mod_smbios(mod);
if (shp == NULL)
Expand Down

0 comments on commit 5cc5d5c

Please sign in to comment.