[v5 15/42] bus/fslmc: free VFIO group FD in case of add group failure
vanshika.shukla at nxp.com
vanshika.shukla at nxp.com
Wed Oct 23 13:59:28 CEST 2024
From: Rohit Raj <rohit.raj at nxp.com>
Free vfio_group_fd if add group fails to avoid resource leak
Signed-off-by: Rohit Raj <rohit.raj at 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
More information about the dev
mailing list