linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find
@ 2022-01-07  8:09 Miaoqian Lin
  2022-01-31 15:25 ` Joerg Roedel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-01-07  8:09 UTC (permalink / raw)
  Cc: linmq006, Thierry Reding, Krishna Reddy, Joerg Roedel,
	Will Deacon, Jonathan Hunter, Nicolin Chen, linux-tegra, iommu,
	linux-kernel

The reference taken by 'of_find_device_by_node()' must be released when
not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Fixes: 765a9d1d02b2 ("iommu/tegra-smmu: Fix mc errors on tegra124-nyan")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/iommu/tegra-smmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index e900e3c46903..2561ce8a2ce8 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -808,8 +808,10 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
 		return NULL;
 
 	mc = platform_get_drvdata(pdev);
-	if (!mc)
+	if (!mc) {
+		put_device(&pdev->dev);
 		return NULL;
+	}
 
 	return mc->smmu;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find
  2022-01-07  8:09 [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find Miaoqian Lin
@ 2022-01-31 15:25 ` Joerg Roedel
  2022-02-16 13:48 ` Thierry Reding
  2022-02-28 12:16 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2022-01-31 15:25 UTC (permalink / raw)
  To: Miaoqian Lin, Thierry Reding
  Cc: Krishna Reddy, Will Deacon, Jonathan Hunter, Nicolin Chen,
	linux-tegra, iommu, linux-kernel

Thierry,

does this look correct to you?

Thanks,

	Joerg

On Fri, Jan 07, 2022 at 08:09:11AM +0000, Miaoqian Lin wrote:
> The reference taken by 'of_find_device_by_node()' must be released when
> not needed anymore.
> Add the corresponding 'put_device()' in the error handling path.
> 
> Fixes: 765a9d1d02b2 ("iommu/tegra-smmu: Fix mc errors on tegra124-nyan")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/iommu/tegra-smmu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index e900e3c46903..2561ce8a2ce8 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -808,8 +808,10 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
>  		return NULL;
>  
>  	mc = platform_get_drvdata(pdev);
> -	if (!mc)
> +	if (!mc) {
> +		put_device(&pdev->dev);
>  		return NULL;
> +	}
>  
>  	return mc->smmu;
>  }
> -- 
> 2.17.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find
  2022-01-07  8:09 [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find Miaoqian Lin
  2022-01-31 15:25 ` Joerg Roedel
@ 2022-02-16 13:48 ` Thierry Reding
  2022-02-28 12:16 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2022-02-16 13:48 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Krishna Reddy, Joerg Roedel, Will Deacon, Jonathan Hunter,
	Nicolin Chen, linux-tegra, iommu, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

On Fri, Jan 07, 2022 at 08:09:11AM +0000, Miaoqian Lin wrote:
> The reference taken by 'of_find_device_by_node()' must be released when
> not needed anymore.
> Add the corresponding 'put_device()' in the error handling path.
> 
> Fixes: 765a9d1d02b2 ("iommu/tegra-smmu: Fix mc errors on tegra124-nyan")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/iommu/tegra-smmu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index e900e3c46903..2561ce8a2ce8 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -808,8 +808,10 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
>  		return NULL;
>  
>  	mc = platform_get_drvdata(pdev);
> -	if (!mc)
> +	if (!mc) {
> +		put_device(&pdev->dev);
>  		return NULL;
> +	}
>  
>  	return mc->smmu;
>  }

Sorry for the late reply, looks correct. We probably also need a similar
call in ->release_device(). I also wonder if we should be returning an
-EPROBE_DEFER here, which is technically the correct thing to do, though
in practice that will likely never happen because these pointers are set
during an arch_initcall, so should always be available by the time a
driver tries to attach to an IOMMU.

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find
  2022-01-07  8:09 [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find Miaoqian Lin
  2022-01-31 15:25 ` Joerg Roedel
  2022-02-16 13:48 ` Thierry Reding
@ 2022-02-28 12:16 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2022-02-28 12:16 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Thierry Reding, Krishna Reddy, Will Deacon, Jonathan Hunter,
	Nicolin Chen, linux-tegra, iommu, linux-kernel

On Fri, Jan 07, 2022 at 08:09:11AM +0000, Miaoqian Lin wrote:
> The reference taken by 'of_find_device_by_node()' must be released when
> not needed anymore.
> Add the corresponding 'put_device()' in the error handling path.
> 
> Fixes: 765a9d1d02b2 ("iommu/tegra-smmu: Fix mc errors on tegra124-nyan")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/iommu/tegra-smmu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied for v5.17, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-28 12:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07  8:09 [PATCH] iommu/tegra-smmu: Fix missing put_device() call in tegra_smmu_find Miaoqian Lin
2022-01-31 15:25 ` Joerg Roedel
2022-02-16 13:48 ` Thierry Reding
2022-02-28 12:16 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).