Re: [PATCH] iommu: Fix refcount leak in iommu_device_claim_dma_owner

From: Jason Gunthorpe
Date: Tue Jan 03 2023 - 18:13:04 EST


On Tue, Jan 03, 2023 at 10:30:17AM +0400, Miaoqian Lin wrote:
> iommu_group_get() returns the group with the reference incremented.
> Also an empty @owner is a more serious problem than refcount leak.
> Move iommu_group_get() after owner check to fix the refcount leak.
>
> Fixes: 89395ccedbc1 ("iommu: Add device-centric DMA ownership interfaces")
> Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx>
> ---
> changes in v2:
> - Remove set NULL to group as suggested by Baolu Lu.
> - Update commit message according to Lu's explanation.
> ---
> drivers/iommu/iommu.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Joerg, can you pick this for rc?

Thanks,
Jason