From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A463C1B10C; Wed, 17 Apr 2019 09:23:42 +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 orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 00:23:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,361,1549958400"; d="scan'208";a="338226049" Received: from dipei-st-npg.sh.intel.com ([10.67.110.220]) by fmsmga006.fm.intel.com with ESMTP; 17 Apr 2019 00:23:40 -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 15:16:28 +0800 Message-Id: <1555485388-50214-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1555483757-48188-1-git-send-email-andy.pei@intel.com> References: <1555483757-48188-1-git-send-email-andy.pei@intel.com> Subject: [dpdk-dev] [PATCH v2] raw/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, 17 Apr 2019 07:23:43 -0000 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 Coverity issue: 279441 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 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 0FFECA00E6 for ; Wed, 17 Apr 2019 09:23:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CC8661B11F; Wed, 17 Apr 2019 09:23:44 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A463C1B10C; Wed, 17 Apr 2019 09:23:42 +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 orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 00:23:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,361,1549958400"; d="scan'208";a="338226049" Received: from dipei-st-npg.sh.intel.com ([10.67.110.220]) by fmsmga006.fm.intel.com with ESMTP; 17 Apr 2019 00:23:40 -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 15:16:28 +0800 Message-Id: <1555485388-50214-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1555483757-48188-1-git-send-email-andy.pei@intel.com> References: <1555483757-48188-1-git-send-email-andy.pei@intel.com> Subject: [dpdk-dev] [PATCH v2] raw/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: <20190417071628.GhPd0jeohVh2Xuv9bSedvHb_icFUbLgTEfpQVxf0CaA@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 Coverity issue: 279441 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