lib/nvme: assign NULL to external_io_msgs ring after free

Multiple nmvme_io_msg producers on the ctrlr share the same ring.
After freeing it, it should be set to NULL. In order to prevent
either nvme_io_msg_ctrlr_detach() or spdk_nvme_io_msg_process()
from interacting on freed memory.

Above happened when resolving issues in later patches.
After their respective fixes, there is no scenario that
solely reproduces this failure so no tests were added in this
patch.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1917 (master)

(cherry picked from commit 251a551aa3)
Change-Id: I72b695d995b63bd002cc03e60cd4bdc82cfbe8ae
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2162
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-04-16 09:54:15 -04:00
parent 6fe32e3e17
commit 7f9ea53d35

View File

@ -155,6 +155,7 @@ nvme_io_msg_ctrlr_register(struct spdk_nvme_ctrlr *ctrlr,
if (ctrlr->external_io_msgs_qpair == NULL) {
SPDK_ERRLOG("spdk_nvme_ctrlr_alloc_io_qpair() failed\n");
spdk_ring_free(ctrlr->external_io_msgs);
ctrlr->external_io_msgs = NULL;
return -ENOMEM;
}
@ -176,6 +177,7 @@ nvme_io_msg_ctrlr_detach(struct spdk_nvme_ctrlr *ctrlr)
if (ctrlr->external_io_msgs) {
spdk_ring_free(ctrlr->external_io_msgs);
ctrlr->external_io_msgs = NULL;
}
if (ctrlr->external_io_msgs_qpair) {