From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 864FBA00BE; Thu, 5 May 2022 07:42:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7099440C35; Thu, 5 May 2022 07:42:12 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 097C440042 for ; Thu, 5 May 2022 07:42:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651729331; x=1683265331; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=g6TEkmVat+tF5vti7/gDyQ9qt+1xfU05wBJ6UbycZ08=; b=P68A9qd3MfHlBGZE0r9AdQHvwMUHTH6MgHwnOALQeKBgYRTClFJJD96b 5lFzVYzKVVjOUmk41XXfR5bPFfb2Fn4B0fisDIOeQGSnCxTDMDR+WbPOj Gviv68RlgY7Sob1pAl6a944xxbCeOWQd9FW69kYftWwdZbyalEmxduyXf y5OWYYaDiFWliiTIH4FOsFbxt+rnxeoBMbVCjTH5K0jALjqGKIcB+/qPD dncUzs3viYcefNr5ZI4+Tttu9vmxQB9E7w5WnSpleZpZkwT7DL61P25fK r9bRZ67yuP7OFUz3qoW/795SuAQXis7aC6A1S4eSalweeKzWLIKkAG5lk w==; X-IronPort-AV: E=McAfee;i="6400,9594,10337"; a="267888242" X-IronPort-AV: E=Sophos;i="5.91,200,1647327600"; d="scan'208";a="267888242" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2022 22:42:10 -0700 X-IronPort-AV: E=Sophos;i="5.91,200,1647327600"; d="scan'208";a="585143317" Received: from unknown (HELO localhost.localdomain) ([10.239.251.209]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2022 22:42:07 -0700 From: Wenwu Ma To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, dev@dpdk.org Cc: jiayu.hu@intel.com, yinan.wang@intel.com, xingguang.he@intel.com, Wenwu Ma Subject: [PATCH] vhost: fix deadlock when handling user messages Date: Thu, 5 May 2022 13:40:08 +0000 Message-Id: <20220505134008.2865-1-wenwux.ma@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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