iommu: rockchip: Free domain on .domain_free
Subsystems (2)
PATCH 1/1 iommu: rockchip: Free domain on .domain_free
IOMMU domain resource life is well-defined, managed by .domain_alloc and .domain_free.
Therefore, domain-specific resources shouldn't be tied to the device life, but instead to its domain.
--- drivers/iommu/rockchip-iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iommu/rockchip-iommu.c +5 -2
@@ -979,13 +979,13 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type)if (!dma_dev)return NULL ; - rk_domain =devm_kzalloc (dma_dev,sizeof (*rk_domain),GFP_KERNEL ); + rk_domain =kzalloc (sizeof (*rk_domain),GFP_KERNEL );if (!rk_domain)return NULL ;if (type ==IOMMU_DOMAIN_DMA &&iommu_get_dma_cookie (&rk_domain->domain)) -return NULL ; + goto err_free_domain;/* * rk32xx iommus use a 2 level pagetable.
@@ -1020,6 +1020,8 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) err_put_cookie:if (type ==IOMMU_DOMAIN_DMA )iommu_put_dma_cookie (&rk_domain->domain); +err_free_domain: +kfree (rk_domain);return NULL ; }
@@ -1048,6 +1050,7 @@ static void rk_iommu_domain_free(struct iommu_domain *domain)if (domain->type ==IOMMU_DOMAIN_DMA )iommu_put_dma_cookie (&rk_domain->domain); +kfree (rk_domain); }static int rk_iommu_add_device (struct device *dev)
Signature · 1 line
2.22.0
Joerg Roedel
maintainerQuoted 7 lines · Ezequiel Garcia
IOMMU domain resource life is well-defined, managed by .domain_alloc and .domain_free.
Therefore, domain-specific resources shouldn't be tied to the device life, but instead to its domain.
Signed-off-by Ezequiel Garcia <[email protected]>
Looks good to me, if Heiko Acks it I apply it for v5.5.
Quoted 5 lines · Ezequiel Garcia
IOMMU domain resource life is well-defined, managed by .domain_alloc and .domain_free.
Therefore, domain-specific resources shouldn't be tied to the device life, but instead to its domain.
FWIW,
Quoted 43 lines
Signed-off-by Ezequiel Garcia <[email protected]>--- drivers/iommu/rockchip-iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/iommu/rockchip-iommu.c +5
-2@@ -979,13 +979,13 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type)if (!dma_dev)return NULL ; - rk_domain =devm_kzalloc (dma_dev,sizeof (*rk_domain),GFP_KERNEL ); + rk_domain =kzalloc (sizeof (*rk_domain),GFP_KERNEL );if (!rk_domain)return NULL ;if (type ==IOMMU_DOMAIN_DMA &&iommu_get_dma_cookie (&rk_domain->domain)) -return NULL ; + goto err_free_domain;/* * rk32xx iommus use a 2 level pagetable. @@ -1020,6 +1020,8 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type) err_put_cookie:if (type ==IOMMU_DOMAIN_DMA )iommu_put_dma_cookie (&rk_domain->domain); +err_free_domain: +kfree (rk_domain);return NULL ; }@@ -1048,6 +1050,7 @@ static void rk_iommu_domain_free(struct iommu_domain *domain)if (domain->type ==IOMMU_DOMAIN_DMA )iommu_put_dma_cookie (&rk_domain->domain); +kfree (rk_domain); }static int rk_iommu_add_device (struct device *dev)
Am Mittwoch, 2. Oktober 2019, 19:29:23 CEST schrieb Ezequiel Garcia:
Quoted 7 lines
IOMMU domain resource life is well-defined, managed by .domain_alloc and .domain_free.
Therefore, domain-specific resources shouldn't be tied to the device life, but instead to its domain.
Signed-off-by Ezequiel Garcia <ezequiel-ZGY8ohtN/[email protected]>
Quoted 10 lines · Ezequiel Garcia
IOMMU domain resource life is well-defined, managed by .domain_alloc and .domain_free.
Therefore, domain-specific resources shouldn't be tied to the device life, but instead to its domain.
Signed-off-by Ezequiel Garcia <[email protected]>--- drivers/iommu/rockchip-iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Applied, thanks.