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...@intel.com Cc: marko.kovace...@intel.com Cc: liq...@163.com Cc: andy....@intel.com Cc: sta...@dpdk.org Signed-off-by: Andy Pei <andy....@intel.com> --- --- 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