]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Ignore NULL address pointer for phy slot lookup
authorDaniel Wagner <dwagner@suse.de>
Thu, 22 Jun 2023 12:09:50 +0000 (14:09 +0200)
committerDaniel Wagner <wagi@monom.org>
Thu, 22 Jun 2023 12:26:52 +0000 (14:26 +0200)
The PCI physical slot lookup works obviously only for physical cards.
Thus do not try to dereference the address pointer if it is a NULL
pointer.

Fixes: 42ac45359635 ("tree: Add PCI physical slot number for controller")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/nvme/tree.c

index 4ba39832fbc39329fe3cc13333d7773697816a12..a2ac0698e59ac8eeb042b5f8e0a93f007b901c42 100644 (file)
@@ -1274,6 +1274,9 @@ static char *nvme_ctrl_lookup_phy_slot(nvme_root_t r, const char *address)
        DIR *slots_dir;
        struct dirent *entry;
 
+       if (!address)
+               return NULL;
+
        slots_dir = opendir(nvme_slots_sysfs_dir);
        if (!slots_dir) {
                nvme_msg(r, LOG_WARNING, "failed to open slots dir %s\n",