From e72453b39f325e4ff57072a11385e45bbf91ca64 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 24 Aug 2021 17:47:29 +0800 Subject: [PATCH] nvmf/vfio-user: don't unmap commands without data buffers libvfio-user will assert if the command didn't have data buffers. Fix issue #2124. Change-Id: I43e9562c614bc65e54dbf650447369317c10f7b5 Signed-off-by: Changpeng Liu Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9264 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Reviewed-by: Dong Yi Reviewed-by: Thanos Makatos Reviewed-by: John Levon --- lib/nvmf/vfio_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/vfio_user.c b/lib/nvmf/vfio_user.c index a7382fb32..a7ca63251 100644 --- a/lib/nvmf/vfio_user.c +++ b/lib/nvmf/vfio_user.c @@ -1328,7 +1328,9 @@ handle_cmd_rsp(struct nvmf_vfio_user_req *vu_req, void *cb_arg) assert(vu_req != NULL); assert(vu_ctrlr != NULL); - vfu_unmap_sg(vu_ctrlr->endpoint->vfu_ctx, vu_req->sg, vu_req->iov, vu_req->iovcnt); + if (spdk_likely(vu_req->iovcnt)) { + vfu_unmap_sg(vu_ctrlr->endpoint->vfu_ctx, vu_req->sg, vu_req->iov, vu_req->iovcnt); + } sqid = vu_qpair->qpair.qid; cqid = vu_ctrlr->qp[sqid]->sq.cqid;