Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3894512iob; Tue, 17 May 2022 09:19:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv4bypGPkS3AftfDIl1de1Vp2FzIOc8EvC7S68UhVmXs97LPsE001+BDVE5EDxSB1cziJT X-Received: by 2002:a05:6a00:cc4:b0:50d:e9db:6145 with SMTP id b4-20020a056a000cc400b0050de9db6145mr23265513pfv.56.1652804355822; Tue, 17 May 2022 09:19:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652804355; cv=pass; d=google.com; s=arc-20160816; b=nTgM2+qbaBMCKrbboDtdVt9D/aHLJth54ztLIQ4OQN4xfh/uEWa28jW918wa7fhI9E Lh1PAnItJhRcgsJ9pZBXqHQD/9BvHujCnpbJGvOAvxmS51UeGEGvDCTzpyXdFA7gHfv/ 7ywF8Uxhm389tg3nSl8f7ssaUIXBMKF9KycN//Fy6i8TG9ZMQTfgD1Mk7B/67NMsL9O4 UPF3szUy6HZtkWR72zyi3FZ+ZmG16cQdjN4pogGgLYp46PdEyRV5Sng9yfHjVXSnOJW6 a0w4uLuDU+m3U/532EzO4Q5xWJJOsmml12fO2zcFcGauYlYRiwir1pXflXIifxeo42Hm luSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=wxRlZEzi0naP2k7nQS45uVFaSUhE5LjAXAVqQe+cA9Q=; b=qvWU+wUVKoQWCl/Vvu7g/z7+k4I/Py+oHd3Zl7EsWQx3UaaEpFRzotZCxhqLJUa0uQ 9a8LK7H+TLKPtMP4EYiilqIgkfBu3CIAbNBCsD4GtEd3SJRFnv1aOCSSdiIrnpqtnRrK U2h0DP1NwhXtEsvHfmxBQbNre6E9ypBM/1ubFjVBJ/1WZe7/Uj+UCKP+HG8lbV40G801 3WQvAUtIaYNdvEWi2yPaFtdV75TqN7XNU5eSH+81ywFUApxGjFd5BFoyjj9eJGPL+W5J rRGV4RBmiRH8sMm+jbBmv2hN6CNQLfzELIK7nWik+eqWlZhbY/EqvQMLWJuTlukYrGYC wYKw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo0.onmicrosoft.com header.s=selector2-vivo0-onmicrosoft-com header.b=hpmqGBMp; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np8-20020a17090b4c4800b001dcd4d33087si4131903pjb.9.2022.05.17.09.19.03; Tue, 17 May 2022 09:19:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo0.onmicrosoft.com header.s=selector2-vivo0-onmicrosoft-com header.b=hpmqGBMp; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232553AbiEQCfE (ORCPT + 99 others); Mon, 16 May 2022 22:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbiEQCfC (ORCPT ); Mon, 16 May 2022 22:35:02 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2102.outbound.protection.outlook.com [40.107.215.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 724A83388A; Mon, 16 May 2022 19:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VKS9ccYFICbgl4MvOU9CIbRwkg+OifQQ81moEiKyxdbw4/5FOfHJFEfqkiSlKdrCdls0HE73r8Tjq2DZ/0lelbPZBhhhFYFTbN8o6EteGCKZF7IjvEwxQBJybe4LE5/mWvzfAC4vh09Y0R4VyAZsjeDBJxzt5KlxUeAC2XX9kjvLLitvIp2WCeOv2nDm7sK6S8xJp/kEQJnTkbpp0s4WF7vxXJPlo1hbD5ZvxFTnPZ/frhTprqrtBvRbtzlgJbno8zB9y4xmPyIgJr1r9vp5VRZROcCD7+mqEn+7yyz7WrTvyVvS1E7gA5PyJiFsPZt2u4hS5PZ0toa6IhlHNhmirQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wxRlZEzi0naP2k7nQS45uVFaSUhE5LjAXAVqQe+cA9Q=; b=PUmFCoC3yP9d7FTzzqBgEXE3huHj7axE0Cnls/uk7fzKyOGM3PGEChjAWcuzyQaKARrFhRi/Pc1I5acmxpH6Qy7L1kCoF6KTTnGCLPUVgRQFnTae7mVHFGNWBJboOL/UpN2UPbjqT5ZiV5VhV9eOCO1LZ9vTRqPrnAvySnej7McvGA3G12UA2WOA3MSU2jJtRYq1XusqS99dGdvUOQZh4sdFEGHT/5lsOb00CMPzExRXYFGUKMAa8ES6F7Hlszz3ImhJqtThx4fdDeTAmCR3QTQo50rYbfJyLtkub9QFoT8jdkn1DEIY/W9cmJy/oTNiAf6ZPmO5PeH0g3PlsSwfsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wxRlZEzi0naP2k7nQS45uVFaSUhE5LjAXAVqQe+cA9Q=; b=hpmqGBMpocKw+fxK2DRxJR0j1qwyXVrkCYI5nbP7pyLppfZ5DPbSyZmCv3CkvNTfIsYCupOm3yRKVqocvF4KyWZFR7WF4wLNpbTdasRnV0ond5qeQisNrnlFlvGgM+IsudnAfHvpDV9xNVyCb7YHXXcZk9bbMkMnwUAq95m/Zyc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SG2PR06MB3367.apcprd06.prod.outlook.com (2603:1096:4:78::19) by HK0PR06MB2484.apcprd06.prod.outlook.com (2603:1096:203:67::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.16; Tue, 17 May 2022 02:34:56 +0000 Received: from SG2PR06MB3367.apcprd06.prod.outlook.com ([fe80::ccb7:f612:80b2:64d5]) by SG2PR06MB3367.apcprd06.prod.outlook.com ([fe80::ccb7:f612:80b2:64d5%4]) with mapi id 15.20.5250.018; Tue, 17 May 2022 02:34:56 +0000 From: Wan Jiabing To: Paolo Bonzini , Alex Williamson , Yi Liu , Kevin Tian , Jason Gunthorpe , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Wan Jiabing Subject: [PATCH] kvm/vfio: Fix potential deadlock problem in vfio Date: Tue, 17 May 2022 10:34:41 +0800 Message-Id: <20220517023441.4258-1-wanjiabing@vivo.com> X-Mailer: git-send-email 2.36.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR03CA0128.apcprd03.prod.outlook.com (2603:1096:4:91::32) To SG2PR06MB3367.apcprd06.prod.outlook.com (2603:1096:4:78::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d759f6cf-2a75-4ddb-5b99-08da37add415 X-MS-TrafficTypeDiagnostic: HK0PR06MB2484:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UXlgygh8gAFaUmLQ4NPm5vBzCiMmEYMtUhPNG/zVuI2EQ7O3tblg4T5APmQP0zmqHkMRnOIpxH9tBMDlVGv3nhuh/X+DpKZWoh646ruwdDmWzOFjAFh/6jeaz9Zn87mFoME7sf1nZCz0DucGw/jRJsd8gX90Zg5631GRutZ/gppuWYMmc7T28qQen4N8odKepHc7rFrIheBK0+QtaF9n7z1GOZz60ykpV0eNk6hVvGrKE38eTkdtKjhH6g+Cjirph+/KQZ/v1V6Q7WccivUZI72oON86jyXf6uEnxvIqAZhMHSIXUwyi0VBuQanYAita4eqd9QGkIT7yE0kYziy2Ru69aetrm3K//I7LBm2ZAAQSMHp+M0UiRsW6LwcV57vl7hJU8LR83/ev/a/YFLYvOMWe5K9CwV7iqm6g57NhjdMAowT2ELnc28kNlfY7cal2XT5y3Oa/8AGTxFozhhCcWvPDNkaJIVLETQ1m/TslKxrh3WXijU/D08Z3w8GlFHiOpc4zz7B57KlQgzu3nJNwdbILRGshkDZeJhfEdk0QB2ABp5SFGwzDOoE7e6tvmrOo+zitVFR+1nTeLHXat40UI0nzo4qBK7JZXQx5mct/7KTT2KxrpokbWK4ypPb3JkTvhW41RiRt2oBD8GrFhxOmzdPEgZi9Xlh/mWGbwhVqlMXavkccfaikDaqNdRn2eQg+74Ei+cYcFCtXV3WE9NbITg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SG2PR06MB3367.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(8676002)(52116002)(4326008)(2906002)(107886003)(38350700002)(6506007)(6666004)(66476007)(4744005)(66556008)(66946007)(5660300002)(8936002)(38100700002)(110136005)(6486002)(86362001)(508600001)(26005)(6512007)(1076003)(316002)(36756003)(2616005)(186003)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0Qx+e1kGuwsokmvN+WDaacX22Gp9GUeOG0AiiJrnUaT+DbBnHOOp70zN6/bz?= =?us-ascii?Q?naw002PFHCAklHxs9C/ugs9HQLxo8vLWD54CfR7K7efX+MfO6EsGYrZtN6I7?= =?us-ascii?Q?jnQppKJLLX7OohPuJ6znuWPuumzZQagxY8rUjiI0qDh3meBP490klVmN6pZr?= =?us-ascii?Q?IsInh+HXbsWkBEcB4g8xnffYHrsCGG/1gBoftdcZ6vcyq9Bfl9wSRFvWrXl/?= =?us-ascii?Q?RuHtAk8uddRL0eB6QzsP7bzi+hVRlld/if8eXAk6FM7o9zjAnfX0HzdBCERb?= =?us-ascii?Q?kw83noDlJy/FfR73+AnlfwWCxcYJlk3wxmgRggCfwXdIZR073hU8W7glbYvj?= =?us-ascii?Q?kjCpG7LWr6akfRvB4umllgLqAXd0ycqC/DOu72y+X26EgYp6+gkWmxj2NV8e?= =?us-ascii?Q?pl4jyHtrlnQBfHSst8bVms9EhQvUY5DZnS9j8syan4sISQT2ArQyzoKgrTQG?= =?us-ascii?Q?PQfoh6IVme8vQvhTwQKAO5rWpj5JuFX1vnpae5lnygUB5vNvRk2Jsv1GN29r?= =?us-ascii?Q?yBx+gIOCAB9zU6MZByWt6oU/sS8DUd/1AAEGY5xg9MizdMjQ4kqSdK7K0O1S?= =?us-ascii?Q?aq0aGch3qojA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20?= =?us-ascii?Q?2qGvYRpYRFuBlhL/xpk5YxvEa7MayqFOrcxUzJoOJVDrBYy1W61eWiEO9F3F?= =?us-ascii?Q?TtBnOPtH06Otrg6aQkZiMgYtekk7ydXJP2g77rppmMQQgR+mI6BNRaWW1uUf?= =?us-ascii?Q?zCgzRvl42rzhbBE4xiIzMwhfsOLSugU4ERlKFC/WDilMtVGNAcO4e3beX6C9?= =?us-ascii?Q?BdXQx/KHNYX+iLVNaySHOFTeWAcxsmoCjp4N9jjWCVH3o6mHxwMKSpm6TKmH?= =?us-ascii?Q?qe7MUGSBEQ=3D=3D?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: d759f6cf-2a75-4ddb-5b99-08da37add415 X-MS-Exchange-CrossTenant-AuthSource: SG2PR06MB3367.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2022 02:34:55.7135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G7N3YJBaUD64SlKjNJX3fbg46etrK2vuLrfT41LN95HoicN4LJFgjC8ZMNoxrISZ73igZoN3LLY1LFHa2G2Gmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK0PR06MB2484 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix following coccicheck warning: ./virt/kvm/vfio.c:258:1-7: preceding lock on line 236 If kvm_vfio_file_iommu_group() failed, code would goto err_fdput with mutex_lock acquired and then return ret. It might cause potential deadlock. Move mutex_unlock bellow err_fdput tag to fix it. Fixes: d55d9e7a45721 ("kvm/vfio: Store the struct file in the kvm_vfio_group") Signed-off-by: Wan Jiabing --- virt/kvm/vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c index 8f9f7fffb96a..ce1b01d02c51 100644 --- a/virt/kvm/vfio.c +++ b/virt/kvm/vfio.c @@ -252,8 +252,8 @@ static int kvm_vfio_group_set_spapr_tce(struct kvm_device *dev, break; } - mutex_unlock(&kv->lock); err_fdput: + mutex_unlock(&kv->lock); fdput(f); return ret; } -- 2.36.1