From nobody Tue May 14 12:39:40 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 1695276838762122.72371047827346; Wed, 20 Sep 2023 23:13:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjCwG-0003VE-0r; Thu, 21 Sep 2023 02:13:24 -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 1qjCwA-0003Tu-Bk for qemu-devel@nongnu.org; Thu, 21 Sep 2023 02:13:18 -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 1qjCw2-0007Vb-Rh for qemu-devel@nongnu.org; Thu, 21 Sep 2023 02:13:18 -0400 Received: from localhost.localdomain [(111.48.58.12)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 970315594; Thu, 21 Sep 2023 14:12:39 +0800 X-UUID: 8bc080a4bcf14f94a4076a9e48557770-20230921 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.31, REQID:22626631-b9af-4a67-ba92-ad2a9dcd1463, IP:15, URL:0,TC:0,Content:21,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:27 X-CID-INFO: VERSION:1.1.31, REQID:22626631-b9af-4a67-ba92-ad2a9dcd1463, IP:15, UR L:0,TC:0,Content:21,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:27 X-CID-META: VersionHash:0ad78a4, CLOUDID:76ce17bf-14cc-44ca-b657-2d2783296e72, B ulkID:23092114124286UVDP68,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: 8bc080a4bcf14f94a4076a9e48557770-20230921 X-User: liucong2@kylinos.cn From: Cong Liu To: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Cc: Cong Liu , qemu-devel@nongnu.org Subject: [PATCH] plugins/hotblocks: Fix potential deadlock in plugin_exit() function Date: Thu, 21 Sep 2023 14:12:31 +0800 Message-Id: <20230921061231.60948-1-liucong2@kylinos.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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: 1695276840251100001 Content-Type: text/plain; charset="utf-8" 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 --- contrib/plugins/hotblocks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index 6b74d25fead6..1f713f1904f3 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -70,6 +70,8 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) =20 g_list_free(it); g_mutex_unlock(&lock); + } else { + g_mutex_unlock(&lock); } =20 qemu_plugin_outs(report->str); --=20 2.34.1