From 194a83d837472a27030e55af95b1103c90c2c63a Mon Sep 17 00:00:00 2001 From: Li Qiang Date: Tue, 16 Apr 2019 13:05:14 +0800 Subject: [PATCH] raw/ifpga: fix file descriptor leak in error path 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 Acked-by: Rosen Xu --- 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 33b2511dea..41be1a205c 100644 --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c @@ -292,7 +292,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.20.1