From patchwork Sun May 22 13:59:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 12858162 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C79CCC4332F for ; Sun, 22 May 2022 13:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346281AbiEVN7I (ORCPT ); Sun, 22 May 2022 09:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244975AbiEVN7H (ORCPT ); Sun, 22 May 2022 09:59:07 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7591B3B01A for ; Sun, 22 May 2022 06:59:05 -0700 (PDT) Received: from pop-os.home ([86.243.180.246]) by smtp.orange.fr with ESMTPA id sm6onkpsUxzw2sm6oniSvB; Sun, 22 May 2022 15:59:04 +0200 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sun, 22 May 2022 15:59:04 +0200 X-ME-IP: 86.243.180.246 From: Christophe JAILLET To: dan.carpenter@oracle.com, "Michael S. Tsirkin" , Jason Wang , Gautam Dawar Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH] vhost-vdpa: Fix some error handling path in vhost_vdpa_process_iotlb_msg() Date: Sun, 22 May 2022 15:59:01 +0200 Message-Id: <89ef0ae4c26ac3cfa440c71e97e392dcb328ac1b.1653227924.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the error paths introduced by the commit in the Fixes tag, a mutex may be left locked. Add the correct goto instead of a direct return. Fixes: a1468175bb17 ("vhost-vdpa: support ASID based IOTLB API") Signed-off-by: Christophe JAILLET Acked-by: Jason Wang Reviewed-by: Stefano Garzarella Acked-by: Michael S. Tsirkin --- WARNING: This patch only fixes the goto vs return mix-up in this function. However, the 2nd hunk looks really spurious to me. I think that the: - return -EINVAL; + r = -EINVAL; + goto unlock; should be done only in the 'if (!iotlb)' block. As I don't know this code, I just leave it as-is but draw your attention in case this is another bug lurking. --- drivers/vhost/vdpa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 1f1d1c425573..3e86080041fc 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -1000,7 +1000,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, if (!as) { dev_err(&v->dev, "can't find and alloc asid %d\n", asid); - return -EINVAL; + r = -EINVAL; + goto unlock; } iotlb = &as->iotlb; } else @@ -1013,7 +1014,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid, } if (!iotlb) dev_err(&v->dev, "no iotlb for asid %d\n", asid); - return -EINVAL; + r = -EINVAL; + goto unlock; } switch (msg->type) {