lib/vmd: return -1 if NVMe driver is not found
Fix issue: potential NULL pointer dereference Change-Id: I23f90616661fdebaacb041bc9f47284231601136 Signed-off-by: GangCao <gang.cao@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14329 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Dong Yi <dongx.yi@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
cdf61c2f22
commit
0b9ba6a330
@ -882,6 +882,7 @@ vmd_init_end_device(struct vmd_pci_device *dev)
|
|||||||
{
|
{
|
||||||
struct vmd_pci_bus *bus = dev->bus;
|
struct vmd_pci_bus *bus = dev->bus;
|
||||||
struct vmd_adapter *vmd;
|
struct vmd_adapter *vmd;
|
||||||
|
struct spdk_pci_driver *driver;
|
||||||
uint8_t bdf[32];
|
uint8_t bdf[32];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -898,7 +899,9 @@ vmd_init_end_device(struct vmd_pci_device *dev)
|
|||||||
SPDK_INFOLOG(vmd, "Initializing NVMe device at %s\n", bdf);
|
SPDK_INFOLOG(vmd, "Initializing NVMe device at %s\n", bdf);
|
||||||
dev->pci.parent = dev->bus->vmd->pci;
|
dev->pci.parent = dev->bus->vmd->pci;
|
||||||
|
|
||||||
rc = spdk_pci_hook_device(spdk_pci_nvme_get_driver(), &dev->pci);
|
driver = spdk_pci_nvme_get_driver();
|
||||||
|
assert(driver != NULL);
|
||||||
|
rc = spdk_pci_hook_device(driver, &dev->pci);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
SPDK_ERRLOG("Failed to hook device %s: %s\n", bdf, spdk_strerror(-rc));
|
SPDK_ERRLOG("Failed to hook device %s: %s\n", bdf, spdk_strerror(-rc));
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user