From patchwork Sat Oct 28 10:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 738944 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp303140wrt; Sat, 28 Oct 2023 03:41:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbY0mbept50Heq82DW/BnrijA7HLVYdfxce2tghSvTRfqQ7GIKCDtfcsoUg1MrYC4aOdGW X-Received: by 2002:a0c:f84a:0:b0:66c:edf4:b955 with SMTP id g10-20020a0cf84a000000b0066cedf4b955mr9661120qvo.21.1698489718336; Sat, 28 Oct 2023 03:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698489718; cv=none; d=google.com; s=arc-20160816; b=Zox3cDjdhgWngK61vLbEyJ8Kp4UuZCshyHjZOFasizPQEPZxtA4kzRL2tQ4BKggUWV Qrv3ioM3MwvCje0t/TltELkEemrFSyM/GdHl/1mSo/+g3mSjXem1hW0wBKwWR+AW6/gd +OpUOoBtBXicEsmbD0lZhEC2QyUP4++GRDu6GP52pEDy6Nml2+9y+rjPqCtMpC6nk9F+ v4D1JWjAcqZrRwERpt3BameWARzl0D5kZ7XgJxhidPFSk/ZB+yFr0xj13ryElAi1FDes +3NnXxMhtqhOreGToJpTkYGZMkoxv0V+uiCLmtXXhzBFmuD8/F45Qi/2YRH6n+27+mBs w3WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7CFsfj+V7ArZMzvtMSrBkmxzQkTGIb36bEletW4AhPo=; fh=FJagK4fJYJ2LOQpwzZAfLijKXfXJqFMUFboG/MsHamE=; b=RIdOvpavlm/B89LR8lureS3W5k1RhBNVbqWj+bV7LmhqXKJEwX3a/3diFj5UT1jLcS 9K+p6aZSUmBBDbmHiy6NfrPCshERVfM5sQ0BLSjm/szqmzKIqlTJwI/1U+BVCc5Nt+Xx jOkzYQdKDVafu92xnLVXcXWjoY4aFl49ZupL3XKvrUdShPZvEcLJSWY6DXogbgWU6H/H tYKl6Z63K5sXnRBfU1lZm/XXUdeRVCA13hyWRzFlr6dlQsDfRdtDs1OPSu+sK/haABrR JN+hMOEwNDC230JzzZPyZtELwI+5CS09CuXmYYN9pLZDVSET5vbC0siUZOtWYMvyNsi7 u3gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VALZNGws; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id or28-20020a056214469c00b0066cfe943369si2263685qvb.358.2023.10.28.03.41.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Oct 2023 03:41:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VALZNGws; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwgkk-0003eX-C0; Sat, 28 Oct 2023 06:41:15 -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 1qwgki-0003cB-8v for qemu-devel@nongnu.org; Sat, 28 Oct 2023 06:41:12 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwgkg-00057p-MO for qemu-devel@nongnu.org; Sat, 28 Oct 2023 06:41:11 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-408382da7f0so21539655e9.0 for ; Sat, 28 Oct 2023 03:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698489669; x=1699094469; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7CFsfj+V7ArZMzvtMSrBkmxzQkTGIb36bEletW4AhPo=; b=VALZNGwsqUvf9PLGZ+SQAblV4T/mnAd6d4Kk0Jr3eT2uv8ZUls9qjl1sIw6UWOck8U Bw1o/BlDrXtC+tlLg4kcLP5hq2AHaeBNVjvx+xV75vCxbaoc3/2uPkw7q6NVRplca72q d8R1wwqBKZgCLFmOd61vr9pkkGKyZvxIk1Itmk9o+u5OYcOFcwHLNt+PDRmri8rzW7n5 9YbucKN8VCSXsv49LtFPG7q9YQ453mW0GJGnoAckdTqpCsbwTL8dx6dYSXXPMTr9Ue9S zzWEOo0NjY1mkRzEZS8oPQb7TZbU4sD5dTU75u8VOgW50EtP3P2zlj8bMEi1uxr9fEIK MUVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698489669; x=1699094469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7CFsfj+V7ArZMzvtMSrBkmxzQkTGIb36bEletW4AhPo=; b=H1VyEaTUvOr+cRhHIukX08ReLX+uCh17gbo8T7JneV3wUP9cLVRnET0eJ22BwyQPdP Bgth6aGy+9vNeCTeKj/MBsvfp3C1Uxrcp22zABpULEM/39DvLujMpCx9IE4pgIarSJ+d lxqEDwI2rskRE5291u5Be16Fyo+jcGmM0Hqg0bZwIkDCul276HtzhL1UmSRoRqLqFxRp GKBJLunNkgDYTqDf3bfLDS/crysdJRI/ceZIFZ3l4ddH0juEiklZ9NLPfh4Fm8EAFes/ HBVXWvdAiu0rTAa1HA4InAS8PKc87ih4O4P+ybkaFIkZ7vgan5DKsLFVnGO3gQWbJ9ry VkXg== X-Gm-Message-State: AOJu0YwDk7K77GhpdHDUKHhWQRTGDR2HC3w2MKw6K5oBacus7oAwut2N 3gWQP8qya/gTzGTrU5kivVY6LQ== X-Received: by 2002:a05:600c:d6:b0:3fe:1232:93fa with SMTP id u22-20020a05600c00d600b003fe123293famr4115956wmm.22.1698489668805; Sat, 28 Oct 2023 03:41:08 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id j7-20020a05600c1c0700b003fefb94ccc9sm3752213wms.11.2023.10.28.03.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 03:41:08 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A74A25F839; Sat, 28 Oct 2023 11:33:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Beraldo Leal , Mahmoud Mandour , Brian Cain , Paolo Bonzini , Warner Losh , Eduardo Habkost , Alexandre Iooss , "Edgar E. Iglesias" , Kyle Evans , qemu-arm@nongnu.org, Aleksandar Rikalo , Aurelien Jarno , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Richard Henderson , Wainer dos Santos Moschetta , Peter Maydell , Brad Smith , Jiaxun Yang , Thomas Huth , Cong Liu Subject: [PATCH 17/17] contrib/plugins: Close file descriptor on error return Date: Sat, 28 Oct 2023 11:33:11 +0100 Message-Id: <20231028103311.347104-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231028103311.347104-1-alex.bennee@linaro.org> References: <20231028103311.347104-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cong Liu 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 Message-Id: <20231018025225.1640122-1-liucong2@kylinos.cn> Signed-off-by: Alex Bennée --- contrib/plugins/lockstep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index f0cb8792c6..237543b43a 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 = AF_UNIX; if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) { perror("bad path"); + close(fd); return false; } @@ -303,6 +304,7 @@ static bool connect_socket(const char *path) sockaddr.sun_family = AF_UNIX; if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) { perror("bad path"); + close(fd); return false; }