From patchwork Sun Oct 29 14:50:33 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: 739064 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp744082wrt; Sun, 29 Oct 2023 07:57:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFO/4+yMiLWUI6k2GskZ4Op5uovsA0t7BpXuqCtg9oJw1u8sEdr5LLGKL1JHKX99AAR2Zcb X-Received: by 2002:ac8:5914:0:b0:41e:2b0b:4908 with SMTP id 20-20020ac85914000000b0041e2b0b4908mr7818472qty.57.1698591431667; Sun, 29 Oct 2023 07:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698591431; cv=none; d=google.com; s=arc-20160816; b=ZGjBmYd5Mu+14WytCnJVpgZEEgPCfF8CD4C+nMuj/UeaVo2VXsCPqgqhV7O+xXLKF/ F5nXnwLS1CH4sCGfQ+E/Grj4kgDgf03yt0OdZ0Ogqfc+vtpCS0yRLt78klPnlhWDPJqf OH9vDY1tQoTze3Khvhzb4U0gbfC58v+mlaYFMXwANSgPIGN+JOcj611ZXrB/y1VJbkpQ OuzUZE96K98YbwgsDK4ymuQamqOfxgf0xEhSCpepbHVNhWtvjP1T+einsQ22J2ISqOV1 wfjPHjQ2sO2Fvfumfd2D/tkwZ6HQuIPpj1HIr3f6iL36d9Tyews6IJPKN0k+oPzT5rU/ K2rQ== 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=1006xl+XCGNGi7Tb1Isf2iUCQhcI8DLGEFBLylxGtCw=; fh=egIzEI8WTXyU+F6KjrikG/bt820+p54VV/6v/kQUIvA=; b=sg7nBlecxTmIpfPT5bFjEtWqUCH4PwiSMVnKiy8NmwjpPjXEcxViYjhztiDmdF8nZS x8oWsp9kldj2N6bKGypDd7Zzi/YL67xoI6D5aY2MRRodF9tWDqcZQTx4DgSYXnPVxpqR 7qJu0ovQUMvkeAMX2mpw1Y6SYgMIgjoQZtjLMhhGvO2WcST3w1MiRfbPPZ8FgltqRbA5 Gn2B3+P1gVy85SOdVvIBtReeKnqQiJXrlqdd2R260/NbOwo5xhA8K0yoJn9W80w9ZvjR +JzfztjUgZ4wKRolFOP30uNqInKCp2qlEktfL5qzZ/2g+AMzna+F7mA6TcH0ibv/oQy5 621A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tYmqkBRN; 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 z18-20020a05622a061200b004180387dcc0si3931013qta.605.2023.10.29.07.57.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 29 Oct 2023 07:57:11 -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=tYmqkBRN; 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 1qx7DE-00035e-ES; Sun, 29 Oct 2023 10:56:25 -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 1qx7DC-00035K-1M for qemu-devel@nongnu.org; Sun, 29 Oct 2023 10:56:23 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qx7D9-0006GZ-9s for qemu-devel@nongnu.org; Sun, 29 Oct 2023 10:56:21 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40891d38e3fso28086045e9.1 for ; Sun, 29 Oct 2023 07:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698591376; x=1699196176; 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=1006xl+XCGNGi7Tb1Isf2iUCQhcI8DLGEFBLylxGtCw=; b=tYmqkBRNKNU+EPrBRL/O7XtsEeuaKdFWyE0fF1Q5Jk9SHFdJCt6VTPCIVtMOxaosMV X1nqxuomjwSazg/ybHF3YamtxD//V2YOKxEp4/3dDpPWfDnGOrOzgOb7yhZU36+MO7IH lhHVyD0NFXWzzuyQb2y0K6EiMzRdY/+vNthSCtjwJtGDkowa1cXhcZs1R/8Oh2h9itLr v3Dz9VYDa4tHJoldRCeHSs8WmMX4XGbZLaLoD06G3Hb9PgxBvQ90luQJiNxE2Bi/blFf qh1ipsmlpGgstXjToXyIrXODcMMcJicEBzD+HKL4a7Ok/W1XBj3A8DpJ7oG5YRSawGz9 d3Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698591376; x=1699196176; 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=1006xl+XCGNGi7Tb1Isf2iUCQhcI8DLGEFBLylxGtCw=; b=mnV42DN7+bhB+Hq3syQRUF8KaDsUktgrKU0OkFe4UncRB32IVokTNshiwEi3XfJamx wVRa4OXFY3D3hqaYDtleAkuyZJsKjmEZzM9G2K+PBefqFeSw6ndKzXGXmwckDh0RCsf+ gjkzo9tSeiIkPu82pkJKKAlC0bZwvb+7QBQ8hybFyXAJrzfJ8qwMnB/b8u3YUWp0kBqp lwWuofO0goLR+faYe0u+T0R9YufzMblQ6acuOtBX+l3KlwHhm6b4xEr53MG2XOhPD7HS tavRsxGgHgBL9bBFfBw5MUDooElZhvw9ZPSYi9g8Q6e8OoFCXYeckp2M1AKBa4Wc7JPs ZFlg== X-Gm-Message-State: AOJu0YypSWJdYF0+RyQX9Jk86Ulg1Cz9iQBJ+wuSvDu/rX0c+IjRGSXB WgGcOyHEpzVcqoLbAkxhCxPtnQ== X-Received: by 2002:a05:600c:1c29:b0:401:eb0:a974 with SMTP id j41-20020a05600c1c2900b004010eb0a974mr6281873wms.3.1698591376630; Sun, 29 Oct 2023 07:56:16 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id p14-20020adfce0e000000b0032f7e2f4457sm3067938wrn.66.2023.10.29.07.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 07:56:16 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D8D456570C; Sun, 29 Oct 2023 14:50:35 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Mahmoud Mandour , Wainer dos Santos Moschetta , Brad Smith , Aleksandar Rikalo , Kyle Evans , Aurelien Jarno , Jiaxun Yang , qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Warner Losh , "Edgar E. Iglesias" , Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , Brian Cain , Alexandre Iooss , Cong Liu Subject: [PATCH v2 19/19] contrib/plugins: Close file descriptor on error return Date: Sun, 29 Oct 2023 14:50:33 +0000 Message-Id: <20231029145033.592566-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231029145033.592566-1-alex.bennee@linaro.org> References: <20231029145033.592566-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.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=unavailable 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 Message-Id: <20231028103311.347104-18-alex.bennee@linaro.org> --- 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; }