From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 56AE35F19 for ; Wed, 10 Apr 2019 15:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=9cljwCzYza0rBXu6jZ a/GQhqX6Fqfh6GoiYl7S1Vv1s=; b=XZxSuNdwgKt+toaX8QsD3r/Xyj+KUjhcgF onQ8wqm5mNG4kEzCqnFkE7LRnRx+79d4k12m9lifXPnhgrdLThD04R48KcTHfFM1 N2su2Abc1/T4J0cJyzA039uBywv1qfflEszjrcPAakG3HwTAdHrHzMqFdtK0dfWY pY39kKa9k= Received: from localhost.localdomain (unknown [183.157.98.195]) by smtp9 (Coremail) with SMTP id DcCowACXJcb38q1crC2dBA--.49S2; Wed, 10 Apr 2019 21:43:36 +0800 (CST) From: Li Qiang To: rosen.xu@intel.com, tianfei.zhang@intel.com Cc: dev@dpdk.org, liq3ea@gmail.com, Li Qiang Date: Wed, 10 Apr 2019 06:43:13 -0700 Message-Id: <20190410134313.5815-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DcCowACXJcb38q1crC2dBA--.49S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFyDuF4xKF1fJF43WryxGrg_yoWDJFX_Zr 92yryxJryYywnrXr1DZ3Wvvr4DKa15WFnavryqgF1rAr15ZFnIq3ykWrsrG3yjqwsrCF1k tryqvrWfZr1UWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU19jjJUUUUU== X-Originating-IP: [183.157.98.195] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbitAKSbVSIbdHXZAAAsa X-Mailman-Approved-At: Wed, 10 Apr 2019 16:02:14 +0200 Subject: [dpdk-dev] [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Apr 2019 13:43:40 -0000 In rte_fpga_do_pr() function, if 'stat' return error the 'file_fd' is never closed thus leading a fd leak. This patch avoids this. Spotted by Coverity: CID 27441 Signed-off-by: Li Qiang --- Changes since v1: fill ret before goto close_fd per Rosen's review drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c index da772d026..eff001b59 100644 --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c @@ -244,7 +244,8 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id, if (ret) { IFPGA_RAWDEV_PMD_ERR("stat on bitstream file failed: %s\n", file_name); - return -EINVAL; + ret = -EINVAL; + goto close_fd; } buffer_size = file_stat.st_size; IFPGA_RAWDEV_PMD_INFO("bitstream file size: %zu\n", buffer_size); -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 68974A0096 for ; Wed, 10 Apr 2019 16:02:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 033AC1B138; Wed, 10 Apr 2019 16:02:15 +0200 (CEST) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 56AE35F19 for ; Wed, 10 Apr 2019 15:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=9cljwCzYza0rBXu6jZ a/GQhqX6Fqfh6GoiYl7S1Vv1s=; b=XZxSuNdwgKt+toaX8QsD3r/Xyj+KUjhcgF onQ8wqm5mNG4kEzCqnFkE7LRnRx+79d4k12m9lifXPnhgrdLThD04R48KcTHfFM1 N2su2Abc1/T4J0cJyzA039uBywv1qfflEszjrcPAakG3HwTAdHrHzMqFdtK0dfWY pY39kKa9k= Received: from localhost.localdomain (unknown [183.157.98.195]) by smtp9 (Coremail) with SMTP id DcCowACXJcb38q1crC2dBA--.49S2; Wed, 10 Apr 2019 21:43:36 +0800 (CST) From: Li Qiang To: rosen.xu@intel.com, tianfei.zhang@intel.com Cc: dev@dpdk.org, liq3ea@gmail.com, Li Qiang Date: Wed, 10 Apr 2019 06:43:13 -0700 Message-Id: <20190410134313.5815-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DcCowACXJcb38q1crC2dBA--.49S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZFyDuF4xKF1fJF43WryxGrg_yoWDJFX_Zr 92yryxJryYywnrXr1DZ3Wvvr4DKa15WFnavryqgF1rAr15ZFnIq3ykWrsrG3yjqwsrCF1k tryqvrWfZr1UWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU19jjJUUUUU== X-Originating-IP: [183.157.98.195] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbitAKSbVSIbdHXZAAAsa X-Mailman-Approved-At: Wed, 10 Apr 2019 16:02:14 +0200 Subject: [dpdk-dev] [PATCH v2] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190410134313.6S4fksR3B-aMa5yUzMxkeLoHCPBubnIccD14tXEIMIY@z> In rte_fpga_do_pr() function, if 'stat' return error the 'file_fd' is never closed thus leading a fd leak. This patch avoids this. Spotted by Coverity: CID 27441 Signed-off-by: Li Qiang --- Changes since v1: fill ret before goto close_fd per Rosen's review drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c index da772d026..eff001b59 100644 --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c @@ -244,7 +244,8 @@ rte_fpga_do_pr(struct rte_rawdev *rawdev, int port_id, if (ret) { IFPGA_RAWDEV_PMD_ERR("stat on bitstream file failed: %s\n", file_name); - return -EINVAL; + ret = -EINVAL; + goto close_fd; } buffer_size = file_stat.st_size; IFPGA_RAWDEV_PMD_INFO("bitstream file size: %zu\n", buffer_size); -- 2.17.1