From nobody Wed Nov 27 16:51:38 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 1697597936973826.2532747250091; Tue, 17 Oct 2023 19:58:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qswlF-0002Wu-Rg; Tue, 17 Oct 2023 22:58:17 -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 1qswlC-0002WU-Lq for qemu-devel@nongnu.org; Tue, 17 Oct 2023 22:58:14 -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 1qswl8-0000qk-Fs for qemu-devel@nongnu.org; Tue, 17 Oct 2023 22:58:14 -0400 Received: from localhost.localdomain [(116.128.244.171)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 45550626; Wed, 18 Oct 2023 10:52:32 +0800 X-UUID: b7606e8e0ebe4f63b9e64fb4c8a9122b-20231018 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32, REQID:ea7cf053-82ea-41c4-9ce0-9ff992556eb7, IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:1 X-CID-INFO: VERSION:1.1.32, REQID:ea7cf053-82ea-41c4-9ce0-9ff992556eb7, IP:10, UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:1 X-CID-META: VersionHash:5f78ec9, CLOUDID:3abf0ec0-14cc-44ca-b657-2d2783296e72, B ulkID:23101810523483AQUDJA,BulkQuantity:0,Recheck:0,SF:66|38|24|17|19|41|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L: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: b7606e8e0ebe4f63b9e64fb4c8a9122b-20231018 X-User: liucong2@kylinos.cn From: Cong Liu To: liucong2@kylinos.cn, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Cc: qemu-devel@nongnu.org Subject: [PATCH v2] contrib/plugins: Close file descriptor on error return Date: Wed, 18 Oct 2023 10:52:25 +0800 Message-Id: <20231018025225.1640122-1-liucong2@kylinos.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016093143.222551-1-liucong2@kylinos.cn> References: <20231016093143.222551-1-liucong2@kylinos.cn> 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: 1697597938968100001 Content-Type: text/plain; charset="utf-8" This patch closes the file descriptor fd on error return to avoid resource leak. Fixes: ec7ee95db909 ("contrib/plugins: fix coverity warning in lockstep") Signed-off-by: Cong Liu --- contrib/plugins/lockstep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index f0cb8792c6fa..237543b43a76 100644 --- a/contrib/plugins/lockstep.c +++ b/contrib/plugins/lockstep.c @@ -257,6 +257,7 @@ static bool setup_socket(const char *path) sockaddr.sun_family =3D AF_UNIX; if (g_strlcpy(sockaddr.sun_path, path, pathlen) >=3D pathlen) { perror("bad path"); + close(fd); return false; } =20 @@ -303,6 +304,7 @@ static bool connect_socket(const char *path) sockaddr.sun_family =3D AF_UNIX; if (g_strlcpy(sockaddr.sun_path, path, pathlen) >=3D pathlen) { perror("bad path"); + close(fd); return false; } =20 --=20 2.34.1