Skip to content

Commit

Permalink
tree: handle no address phy slot dirs
Browse files Browse the repository at this point in the history
Not all directories have an address. Verify addr before calling
strcmp().

Fixes: 42ac453 ("tree: Add PCI physical slot number for controller")
Signed-off-by: Greg Joyce <[email protected]>
  • Loading branch information
gjoyce-ibm authored and igaw committed Aug 1, 2024
1 parent f54a1fe commit 49a4cd8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,10 @@ static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
return NULL;
}
addr = nvme_get_attr(path, "address");

/* some directories don't have an address entry */
if (!addr)
continue;
if (strcmp(addr, target_addr) == 0)
return strdup(entry->d_name);
}
Expand Down

0 comments on commit 49a4cd8

Please sign in to comment.