From 156ae159a8f191ad0da939235787c11a7c6b1aa1 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 22 Nov 2018 17:25:29 +0100 Subject: [PATCH] nvme: fix pci device leak when detaching a controller in primary process This case isn't particularly supported, but still caused a memory leak and rendered the pci device inaccessible for the rest of the primary process lifetime. This happens when a controller is removed from the primary process while a secondary process still uses it. The controller will likely misbehave without its primary process managing it, but at least there won't be a leak. Change-Id: I67581cffa33ce14ff516b5743d13c9ef7b351625 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/434408 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448366 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvme/nvme_ctrlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index df94396db..f83ceb295 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -1650,7 +1650,7 @@ nvme_ctrlr_remove_process(struct spdk_nvme_ctrlr *ctrlr, TAILQ_REMOVE(&ctrlr->active_procs, proc, tailq); - if (!proc->is_primary && ctrlr->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) { + if (ctrlr->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) { spdk_pci_device_detach(proc->devhandle); }