From: Rohit Raj <rohit....@nxp.com> Free vfio_group_fd if add group fails to avoid resource leak
Signed-off-by: Rohit Raj <rohit....@nxp.com> --- drivers/bus/fslmc/fslmc_vfio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 63e84cb4d8..3d466d3f1f 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -343,8 +343,10 @@ fslmc_vfio_open_group_fd(const char *group_name) } else { ret = fslmc_vfio_add_group(vfio_group_fd, iommu_group_num, group_name); - if (ret) + if (ret) { + close(vfio_group_fd); return ret; + } } return vfio_group_fd; -- 2.25.1