From nobody Mon Apr 29 12:52:41 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 ARC-Seal: i=1; a=rsa-sha256; t=1604911278; cv=none; d=zohomail.com; s=zohoarc; b=ZHIklL9IKgD0TVSJANSUT/imDl4QFXK4C9I2doYjrCkwtIhENQU9pirGfr678WQ2Qkcu798hfEznF8HAB130vj/2qEHsoSeK7AZQn35IRxcTfEKArUAzSzoKIIZ+UeH3i1nnFE/um+yZjEvuAsKtJOALU/QSD/fGyVDU3htP6Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604911278; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KvV+3vEy/MD5O9YJQ6oBeF2yv+o3SSVbbxYRQgxNUJI=; b=BlPl6lzlqol3c9e3vxYWkj9q0En3DZa59redvBHxSDo6uleyRgjxDIx9J5vzRtcw/yQln6PNK9Jgd/VaeXqgdvDAjdTg+Uo1z0VS8Ighc1qYuR9DrnIRXPKTUYbW5V/z0bfwIpaUd6GSNR4D88a3Sh9XTYhgQA05oTJHzdje4vo= ARC-Authentication-Results: i=1; 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 1604911278937606.7651148317535; Mon, 9 Nov 2020 00:41:18 -0800 (PST) Received: from localhost ([::1]:35308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kc2jl-0004s9-Tc for importer@patchew.org; Mon, 09 Nov 2020 03:41:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc2iE-0003bH-Q1; Mon, 09 Nov 2020 03:39:42 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc2iC-0004a6-T6; Mon, 09 Nov 2020 03:39:42 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CV4DC68GDzLtwp; Mon, 9 Nov 2020 16:39:23 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Mon, 9 Nov 2020 16:39:26 +0800 From: Alex Chen To: , , Subject: [PATCH v3 1/2] plugins: Fix resource leak in connect_socket() Date: Mon, 9 Nov 2020 08:28:28 +0000 Message-ID: <20201109082829.87496-2-alex.chen@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20201109082829.87496-1-alex.chen@huawei.com> References: <20201109082829.87496-1-alex.chen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected 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=45.249.212.191; envelope-from=alex.chen@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/09 03:39:34 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, qemu-trivial@nongnu.org, qemu-devel@nongnu.org, zhengchuan@huawei.com, zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Close the fd when the connect() fails. Reported-by: Euler Robot Signed-off-by: Alex Chen --- contrib/plugins/lockstep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index a696673dff..319bd44b83 100644 --- a/contrib/plugins/lockstep.c +++ b/contrib/plugins/lockstep.c @@ -292,6 +292,7 @@ static bool connect_socket(const char *path) =20 if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) { perror("failed to connect"); + close(fd); return false; } =20 --=20 2.19.1 From nobody Mon Apr 29 12:52:41 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 ARC-Seal: i=1; a=rsa-sha256; t=1604911361; cv=none; d=zohomail.com; s=zohoarc; b=mj1UUd7ldL3mvdMih505ZhsEE7lb2e6x4yDUw9R1zj1GOZqYEbCdfyjZR66Gtc0It1Vd/nLAM+nOv3dV7FuOQ+SdHTp3/r3Zw/vhubmXdMgd8jG0s9reVeaU7RayHX97iB67BU/TJoDKK1kY/C2UbNoeS8U6wyMZoctODn5vXac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604911361; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=36XnY7cgrJ4qS9+cC6nfuR4dsL7TG9aZvjkzrhJbwcs=; b=lgqL6sl5XYbvLljAA2td7RH5VJNwphmQteqXrQ37++affoyrkmIETBfFhs7g//GBmTTmwEq+izLFA9iGMPjoZd9ykaW4C+p9sm/8HJdr3sx9nRUteL+lV6IlYebS3Pw1qq+q5sCnhzF1/Qtqlizv90Eh7Yeld/JsGpmRWLfFxqU= ARC-Authentication-Results: i=1; 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 1604911361563571.6243201636782; Mon, 9 Nov 2020 00:42:41 -0800 (PST) Received: from localhost ([::1]:38584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kc2l6-0006EQ-Hv for importer@patchew.org; Mon, 09 Nov 2020 03:42:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc2iD-0003ay-Kj; Mon, 09 Nov 2020 03:39:41 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kc2iA-0004a5-Ua; Mon, 09 Nov 2020 03:39:41 -0500 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CV4DC6bSczLvsl; Mon, 9 Nov 2020 16:39:23 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Mon, 9 Nov 2020 16:39:27 +0800 From: Alex Chen To: , , Subject: [PATCH v3 2/2] plugins: Fix two resource leaks in setup_socket() Date: Mon, 9 Nov 2020 08:28:29 +0000 Message-ID: <20201109082829.87496-3-alex.chen@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20201109082829.87496-1-alex.chen@huawei.com> References: <20201109082829.87496-1-alex.chen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected 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=45.249.212.191; envelope-from=alex.chen@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/09 03:39:34 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, qemu-trivial@nongnu.org, qemu-devel@nongnu.org, zhengchuan@huawei.com, zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Either accept() fails or exits normally, we need to close the fd. Reported-by: Euler Robot Signed-off-by: Alex Chen --- contrib/plugins/lockstep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index 319bd44b83..5aad50869d 100644 --- a/contrib/plugins/lockstep.c +++ b/contrib/plugins/lockstep.c @@ -268,11 +268,13 @@ static bool setup_socket(const char *path) socket_fd =3D accept(fd, NULL, NULL); if (socket_fd < 0 && errno !=3D EINTR) { perror("accept socket"); + close(fd); return false; } =20 qemu_plugin_outs("setup_socket::ready\n"); =20 + close(fd); return true; } =20 --=20 2.19.1