From nobody Tue May 14 21:30:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695288268779935.577020851858; Thu, 21 Sep 2023 02:24:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjFuS-0003lT-KL; Thu, 21 Sep 2023 05:23:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjFuL-0003kP-T1 for qemu-devel@nongnu.org; Thu, 21 Sep 2023 05:23:39 -0400 Received: from mailgw.kylinos.cn ([124.126.103.232]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjFuC-0002ez-2i for qemu-devel@nongnu.org; Thu, 21 Sep 2023 05:23:35 -0400 Received: from localhost.localdomain [(111.48.58.12)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 150126022; Thu, 21 Sep 2023 17:23:18 +0800 X-UUID: 66aa0a87dfd346bbb0c3fbcc420f172a-20230921 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31, REQID:c8cd7c02-d953-459e-9970-84698d566a20, IP:15, URL:0,TC:0,Content:20,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:26 X-CID-INFO: VERSION:1.1.31, REQID:c8cd7c02-d953-459e-9970-84698d566a20, IP:15, UR L:0,TC:0,Content:20,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:26 X-CID-META: VersionHash:0ad78a4, CLOUDID:e91e1abf-14cc-44ca-b657-2d2783296e72, B ulkID:230921172319DHNO8PRM,BulkQuantity:0,Recheck:0,SF:38|24|17|19|43|102, TC:nil,Content:4,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 66aa0a87dfd346bbb0c3fbcc420f172a-20230921 X-User: liucong2@kylinos.cn From: Cong Liu To: philmd@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Cc: liucong2@kylinos.cn, qemu-devel@nongnu.org Subject: [PATCH v2] plugins/hotblocks: Fix potential deadlock in plugin_exit() function Date: Thu, 21 Sep 2023 17:23:11 +0800 Message-Id: <20230921092311.15578-1-liucong2@kylinos.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <8c11bc64-e22f-6ad9-af3e-e7a690536539@linaro.org> References: <8c11bc64-e22f-6ad9-af3e-e7a690536539@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=124.126.103.232; envelope-from=liucong2@kylinos.cn; helo=mailgw.kylinos.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1695288271069100001 This patch fixes a potential deadlock in the plugin_exit() function of QEMU. The original code does not release the lock mutex if it is NULL. This patch adds a check for it being NULL and releases the mutex in that case. Signed-off-by: Cong Liu Suggested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- contrib/plugins/hotblocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 6b74d25fead6..b99b93ad8dc7 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -69,9 +69,9 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) } =20 g_list_free(it); - g_mutex_unlock(&lock); } =20 + g_mutex_unlock(&lock); qemu_plugin_outs(report->str); } =20 --=20 2.34.1