In nvme_ctrl_lookup_phy_slot(), we are missing a closedir(), which
causes file descriptors to leak. Also, there was a missing free()
when the function returns with ENOMEM.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
ret = asprintf(&path, "/sys/bus/pci/slots/%s", entry->d_name);
if (ret < 0) {
errno = ENOMEM;
+ free(target_addr);
+ closedir(slots_dir);
return NULL;
}
addr = nvme_get_attr(path, "address");
}
}
free(target_addr);
+ closedir(slots_dir);
if (found)
return strdup(entry->d_name);
return NULL;