[v1 15/43] bus/fslmc: free VFIO group FD in case of add group failure
vanshika.shukla at nxp.com
vanshika.shukla at nxp.com
Fri Sep 13 07:59:31 CEST 2024
From: Rohit Raj <rohit.raj at nxp.com>
Free vfio_group_fd if add group fails to avoid ersource leak
NXP coverity-id: 26661846
Signed-off-by: Rohit Raj <rohit.raj at nxp.com>
---
drivers/bus/fslmc/fslmc_vfio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index c6a010922e..b550066183 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -347,8 +347,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;
@@ -1481,6 +1483,8 @@ fslmc_vfio_setup_group(void)
if (vfio_group_fd <= 0) {
vfio_group_fd = fslmc_vfio_open_group_fd(group_name);
if (vfio_group_fd <= 0) {
+ if (!vfio_group_fd)
+ close(vfio_group_fd);
DPAA2_BUS_ERR("Failed to create MC VFIO group");
return -rte_errno;
}
--
2.25.1
More information about the dev
mailing list