Skip to content

Commit

Permalink
iommu: Fix reference count leak in iommu_group_alloc.
Browse files Browse the repository at this point in the history
[ Upstream commit 7cc3161 ]

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: d72e31c ("iommu: IOMMU Groups")
Signed-off-by: Qiushi Wu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
QiushiWu authored and gregkh committed Jun 3, 2020
1 parent b298c31 commit ca788fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,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);
}

Expand Down

0 comments on commit ca788fd

Please sign in to comment.