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 BACDBA00E6 for ; Wed, 17 Apr 2019 08:56:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D97ED1B579; Wed, 17 Apr 2019 08:56:50 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 7227E1B4DE; Wed, 17 Apr 2019 08:56:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2019 23:56:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,361,1549958400"; d="scan'208";a="338220289" Received: from dipei-st-npg.sh.intel.com ([10.67.110.220]) by fmsmga006.fm.intel.com with ESMTP; 16 Apr 2019 23:56:47 -0700 From: Andy Pei To: dev@dpdk.org Cc: andy.pei@intel.com, rosen.xu@intel.com, marko.kovacevic@intel.com, liq3ea@163.com, stable@dpdk.org Date: Wed, 17 Apr 2019 14:49:17 +0800 Message-Id: <1555483757-48188-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] raw/ifpga: 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: <20190417064917.B6-IdfDq9X4HBJ0N_pvYfeVxLzXaq0nA-iLEcHyZYpA@z> In rte_fpga_do_pr() function, if 'stat' returns error, rte_fpga_do_pr() returns -EINVAL without closing the 'file_fd' that has been opened. After this patch, 'file_fd' is closed before rte_fpga_do_pr() returns -EINVAL when 'stat' returns error Fixes: ef1e8ede3da5 ("raw/ifpga: add Intel FPGA bus rawdev driver") Cc: rosen.xu@intel.com Cc: marko.kovacevic@intel.com Cc: liq3ea@163.com Cc: andy.pei@intel.com Cc: stable@dpdk.org Signed-off-by: Andy Pei --- --- 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 da772d0..eff001b 100644 --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c @@ -244,7 +244,8 @@ 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); -- 1.8.3.1