From 251a551aa3102e1a9de7260c7eacb6de2c8fa074 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Thu, 16 Apr 2020 09:54:15 -0400 Subject: [PATCH] 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 Change-Id: I72b695d995b63bd002cc03e60cd4bdc82cfbe8ae Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1917 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvme/nvme_io_msg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/nvme/nvme_io_msg.c b/lib/nvme/nvme_io_msg.c index dfaa490063..041622f67e 100644 --- a/lib/nvme/nvme_io_msg.c +++ b/lib/nvme/nvme_io_msg.c @@ -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) {