[v3] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr

Message ID 20190416050514.2784-1-liq3ea@163.com
State Accepted, archived
Delegated to: Thomas Monjalon
Headers show
Series
  • [v3] drivers: ifpga_rawdev: fix fd leak in rte_fpga_do_pr
Related show

Checks

Context Check Description
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Li Qiang April 16, 2019, 5:05 a.m.
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.

Coverity issue: 279441
Fixes: ef1e8ede3da59e("raw/ifpga: add Intel FPGA bus rawdev driver")
Cc: stable@dpdk.org

Signed-off-by: Li Qiang <liq3ea@163.com>
---
Change since v2: add proper tags in commit message

 drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Thomas Monjalon May 2, 2019, 9:39 p.m. | #1
> > 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.
> > 
> > Coverity issue: 279441
> > Fixes: ef1e8ede3da59e("raw/ifpga: add Intel FPGA bus rawdev driver")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> 
> Acked-by: Rosen Xu <rosen.xu@intel.com>

Applied, thanks

Patch

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);