From b6e01459f3e03513fc091337f258c092c8d9112f Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 28 Dec 2021 13:52:22 +0900 Subject: [PATCH] nvmf: Disconnect qpair whose ctrlr is not set yet when removing listener We have very frequent failures when we run test/nvmf/host/multipath.sh in the test pool. Call stack showed nvmf_stop_listen_disconnect_qpairs() accessed qpair->ctrlr even if qpair->ctrlr was NULL. nvmf_stop_listen_disconnect_qpairs() did not check if qpair->ctrlr is not NULL before accessing qpair->ctrlr->subsys. When a qpair is added to a poll group, qpair->ctrlr is cleared to NULL. The test code test/nvmf/host/multipath.sh executes multiple reconnects for path error. So a conflict might occur between adding a qpair to a poll group and disconnecting a qpair in a poll group. In this case, it may be acceptable even if we disconnect a qpair whose qpair->ctrlr is NULL. It will be better than SIGSEGV. Fixes one of the issues in #2300 Signed-off-by: Shuhei Matsumoto Change-Id: I308fcb886dd410d01e3361c1850dec9a8eacbccf Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10860 Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins --- lib/nvmf/transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nvmf/transport.c b/lib/nvmf/transport.c index a261b565a..ab7e6a773 100644 --- a/lib/nvmf/transport.c +++ b/lib/nvmf/transport.c @@ -410,7 +410,7 @@ nvmf_stop_listen_disconnect_qpairs(struct spdk_io_channel_iter *i) } if (!spdk_nvme_transport_id_compare(&ctx->trid, &tmp_trid)) { - if (ctx->subsystem == NULL || + if (ctx->subsystem == NULL || qpair->ctrlr == NULL || ctx->subsystem == qpair->ctrlr->subsys) { spdk_nvmf_qpair_disconnect(qpair, NULL, NULL); }