Skip to contentSkip to conversation

iommu: Fix reference count leak in iommu_group_alloc.

PATCH Applied [email protected] 2 participants 2 messages May 27, 2020 – May 29, 2020 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: Fix reference count leak in iommu_group_alloc.

From: Qiushi Wu <[email protected]>

kobject_init_and_add() takes reference even when it fails. Thus, when kobject_init_and_add() returns an error, kobject_put() must be called to properly clean up the kobject.

Fixes d72e31c93746 ("iommu: IOMMU Groups")
---
 drivers/iommu/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommu.c +1 -1
index 1faa08c8bbb4..03d6a26687bc 100644
@@ -510,7 +510,7 @@ struct iommu_group *iommu_group_alloc(void)
 				   NULL, "%d", group->id);
 	if (ret) {
 		ida_simple_remove(&iommu_group_ida, group->id);
-		kfree(group);
+		kobject_put(&group->kobj);
 		return ERR_PTR(ret);
 	}
 
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 11 lines · On Wed, May 27, 2020 at 04:00:19PM -0500, [email protected] wrote:

From: Qiushi Wu <[email protected]>

kobject_init_and_add() takes reference even when it fails. Thus, when kobject_init_and_add() returns an error, kobject_put() must be called to properly clean up the kobject.

Fixes d72e31c93746 ("iommu: IOMMU Groups")
---
 drivers/iommu/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.