iommu: Fix error unwind in iommu_group_alloc()
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 16 Feb 2023 01:21:16 +0000 (21:21 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:42 +0000 (09:39 +0100)
commitf119ef452e2d82d912797273cb790a86f1125b3e
tree5cca77dbf26c5c2b86aa946b45d438e83605e8c7
parent76e0396313c79ecd0df44ee3c18745cfac52b3e6
iommu: Fix error unwind in iommu_group_alloc()

[ Upstream commit 4daa861174d56023c2068ddb03de0752f07fa199 ]

If either iommu_group_grate_file() fails then the
iommu_group is leaked.

Destroy it on these error paths.

Found by kselftest/iommu/iommufd_fail_nth

Fixes: bc7d12b91bd3 ("iommu: Implement reserved_regions iommu-group sysfs file")
Fixes: c52c72d3dee8 ("iommu: Add sysfs attribyte for domain type")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/0-v1-8f616bee028d+8b-iommu_group_alloc_leak_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/iommu.c