Skip to contentSkip to conversation

vfio: Fix memory leaks in vfio_create_group()

PATCH In review Lei Rao 2 participants 2 messages Jun 29, 2022

Subsystems (2)
lore
Share & tools
lore

Lei Rao

author
#0 lore raw

PATCH 1/1 vfio: Fix memory leaks in vfio_create_group()

If an error occurs after vfio_group_alloc(), we need to release the group.

---
 drivers/vfio/vfio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vfio/vfio.c +1 -0
index 61e71c1154be..2460aec44a6d 100644
@@ -414,6 +414,7 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group,
 	mutex_unlock(&vfio.group_lock);
 err_put:
 	put_device(&group->dev);
+	vfio_group_release(&group->dev);
 	return ret;
 }
 
Signature · 1 line
2.32.0
#1 lore raw
Quoted 16 lines

From: Rao, Lei <[email protected]>
Sent: Wednesday, June 29, 2022 10:05 AM

If an error occurs after vfio_group_alloc(), we need to release the group.

---
 drivers/vfio/vfio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/vfio/vfio.c +0 -0
index 61e71c1154be..2460aec44a6d 100644

drivers/vfio/vfio.c static struct vfio_group *vfio_create_group(struct · line 418

Quoted 5 lines
drivers/vfio/vfio.c +1 -0
@@ -414,6 +414,7 @@ static struct vfio_group *vfio_create_group(struct
 iommu_group *iommu_group,
 	mutex_unlock(&vfio.group_lock);
 err_put:
 	put_device(&group->dev);
+	vfio_group_release(&group->dev);

this is called automatically by put_device().

Quoted 5 lines
drivers/vfio/vfio.c +0 -1
 	return ret;
 }
 
--

2.32.0