[PATCH] vhost: fix deadlock when handling user messages

Wenwu Ma wenwux.ma at intel.com
Thu May 5 15:40:08 CEST 2022


In vhost_user_msg_handler(), if vhost message handling
failed, we should check whether the queue is locked and
release the lock before returning. Or, it will cause a
deadlock later.

Signed-off-by: Wenwu Ma <wenwux.ma at intel.com>
---
 lib/vhost/vhost_user.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
index 1d390677fa..80a5df6e9d 100644
--- a/lib/vhost/vhost_user.c
+++ b/lib/vhost/vhost_user.c
@@ -3113,6 +3113,8 @@ vhost_user_msg_handler(int vid, int fd)
 		send_vhost_reply(dev, fd, &ctx);
 	} else if (ret == RTE_VHOST_MSG_RESULT_ERR) {
 		VHOST_LOG_CONFIG(ERR, "(%s) vhost message handling failed.\n", dev->ifname);
+		if (unlock_required)
+			vhost_user_unlock_all_queue_pairs(dev);
 		return -1;
 	}
 
-- 
2.25.1



More information about the dev mailing list