nvme: verify remove_cb is non-NULL before calling

This fixes the VFIO hot-remove path, which called remove_cb without
checking to see if it had been specified by the user.  The normal uevent
removal path already checked for remove_cb.

Change-Id: I0ad8d2c90a77b16800a8b505cb69ea05b0706d70
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/408392
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Daniel Verkamp 2018-04-19 13:04:00 -07:00
parent 3fa7c33ac1
commit 8e098e4190

View File

@ -299,9 +299,11 @@ _nvme_pcie_hotplug_monitor(void *cb_ctx, spdk_nvme_probe_cb probe_cb,
csts = spdk_nvme_ctrlr_get_regs_csts(ctrlr);
if (csts.raw == 0xffffffffU) {
nvme_ctrlr_fail(ctrlr, true);
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
remove_cb(cb_ctx, ctrlr);
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
if (remove_cb) {
nvme_robust_mutex_unlock(&g_spdk_nvme_driver->lock);
remove_cb(cb_ctx, ctrlr);
nvme_robust_mutex_lock(&g_spdk_nvme_driver->lock);
}
}
}
return 0;