* [PATCH RESEND] ARM: tegra: fix device leak on tegra ahb lookup
@ 2025-12-14 12:53 Ma Ke
2025-12-15 20:03 ` Jon Hunter
0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2025-12-14 12:53 UTC (permalink / raw)
To: linux, thierry.reding, jonathanh, make24, johan, hdoyu, swarren
Cc: linux-tegra, linux-kernel, akpm, stable
tegra_ahb_enable_smmu() utilizes driver_find_device_by_of_node() which
internally calls driver_find_device() to locate the matching device.
driver_find_device() increments the ref count of the found device by
calling get_device(), but tegra_ahb_enable_smmu() fails to call
put_device() to decrement the reference count before returning. This
results in a reference count leak of the device, which may prevent the
device from being properly released and cause a memory leak.
Found by code review.
Cc: stable@vger.kernel.org
Fixes: 89c788bab1f0 ("ARM: tegra: Add SMMU enabler in AHB")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
drivers/amba/tegra-ahb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
index f23c3ed01810..3ed5cef34806 100644
--- a/drivers/amba/tegra-ahb.c
+++ b/drivers/amba/tegra-ahb.c
@@ -148,6 +148,7 @@ int tegra_ahb_enable_smmu(struct device_node *dn)
val = gizmo_readl(ahb, AHB_ARBITRATION_XBAR_CTRL);
val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE;
gizmo_writel(ahb, val, AHB_ARBITRATION_XBAR_CTRL);
+ put_device(dev);
return 0;
}
EXPORT_SYMBOL(tegra_ahb_enable_smmu);
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] ARM: tegra: fix device leak on tegra ahb lookup
2025-12-14 12:53 [PATCH RESEND] ARM: tegra: fix device leak on tegra ahb lookup Ma Ke
@ 2025-12-15 20:03 ` Jon Hunter
0 siblings, 0 replies; 2+ messages in thread
From: Jon Hunter @ 2025-12-15 20:03 UTC (permalink / raw)
To: Ma Ke, linux, thierry.reding, johan, hdoyu, swarren
Cc: linux-tegra, linux-kernel, akpm, stable
On 14/12/2025 12:53, Ma Ke wrote:
> tegra_ahb_enable_smmu() utilizes driver_find_device_by_of_node() which
> internally calls driver_find_device() to locate the matching device.
> driver_find_device() increments the ref count of the found device by
> calling get_device(), but tegra_ahb_enable_smmu() fails to call
> put_device() to decrement the reference count before returning. This
> results in a reference count leak of the device, which may prevent the
> device from being properly released and cause a memory leak.
>
> Found by code review.
>
> Cc: stable@vger.kernel.org
> Fixes: 89c788bab1f0 ("ARM: tegra: Add SMMU enabler in AHB")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> drivers/amba/tegra-ahb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c
> index f23c3ed01810..3ed5cef34806 100644
> --- a/drivers/amba/tegra-ahb.c
> +++ b/drivers/amba/tegra-ahb.c
> @@ -148,6 +148,7 @@ int tegra_ahb_enable_smmu(struct device_node *dn)
> val = gizmo_readl(ahb, AHB_ARBITRATION_XBAR_CTRL);
> val |= AHB_ARBITRATION_XBAR_CTRL_SMMU_INIT_DONE;
> gizmo_writel(ahb, val, AHB_ARBITRATION_XBAR_CTRL);
> + put_device(dev);
> return 0;
> }
> EXPORT_SYMBOL(tegra_ahb_enable_smmu);
This has already been fixed and so this change is not needed.
--
nvpublic
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-15 20:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-14 12:53 [PATCH RESEND] ARM: tegra: fix device leak on tegra ahb lookup Ma Ke
2025-12-15 20:03 ` Jon Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®