public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup
@ 2025-11-21 12:18 Johan Hovold
  2025-11-21 12:59 ` Krzysztof Kozlowski
  2025-11-27 15:56 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 5+ messages in thread
From: Johan Hovold @ 2025-11-21 12:18 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Alim Akhtar
  Cc: Peter Griffin, linux-samsung-soc, linux-kernel, Johan Hovold,
	stable

Make sure to drop the reference taken when looking up the PMU device and
its regmap.

Note that holding a reference to a device does not prevent its regmap
from going away so there is no point in keeping the reference.

Fixes: 0b7c6075022c ("soc: samsung: exynos-pmu: Add regmap support for SoCs that protect PMU regs")
Cc: stable@vger.kernel.org	# 6.9
Cc: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/soc/samsung/exynos-pmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
index 22c50ca2aa79..ba4de8194a0e 100644
--- a/drivers/soc/samsung/exynos-pmu.c
+++ b/drivers/soc/samsung/exynos-pmu.c
@@ -346,6 +346,8 @@ struct regmap *exynos_get_pmu_regmap_by_phandle(struct device_node *np,
 	if (!dev)
 		return ERR_PTR(-EPROBE_DEFER);
 
+	put_device(dev);
+
 	return syscon_node_to_regmap(pmu_np);
 }
 EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap_by_phandle);
-- 
2.51.2


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

* Re: [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup
  2025-11-21 12:18 [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup Johan Hovold
@ 2025-11-21 12:59 ` Krzysztof Kozlowski
  2025-11-21 15:03   ` Johan Hovold
  2025-11-27 15:56 ` Krzysztof Kozlowski
  1 sibling, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-21 12:59 UTC (permalink / raw)
  To: Johan Hovold, Alim Akhtar
  Cc: Peter Griffin, linux-samsung-soc, linux-kernel, stable

On 21/11/2025 13:18, Johan Hovold wrote:
> Make sure to drop the reference taken when looking up the PMU device and
> its regmap.
> 
> Note that holding a reference to a device does not prevent its regmap
> from going away so there is no point in keeping the reference.

Thanks for the patch, it's 3rd or fourth try from LKML on that, but you
were the only one actually really reading the code instead of sprinking
puts all around.

> 
> Fixes: 0b7c6075022c ("soc: samsung: exynos-pmu: Add regmap support for SoCs that protect PMU regs")
> Cc: stable@vger.kernel.org	# 6.9

Fix is fine, but unfortunately the code in v6.9 was different and I
believe keeping dev reference made sense there - driver was relying on
drvdata. While the leak was there as well, it was intentional. I think
the leak can be fixed only since commit
35d6b98c625867209bc47df99cf03edf4280799f .


Best regards,
Krzysztof

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

* Re: [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup
  2025-11-21 12:59 ` Krzysztof Kozlowski
@ 2025-11-21 15:03   ` Johan Hovold
  2025-11-27 15:55     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2025-11-21 15:03 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Alim Akhtar, Peter Griffin, linux-samsung-soc, linux-kernel,
	stable

On Fri, Nov 21, 2025 at 01:59:59PM +0100, Krzysztof Kozlowski wrote:
> On 21/11/2025 13:18, Johan Hovold wrote:
> > Make sure to drop the reference taken when looking up the PMU device and
> > its regmap.
> > 
> > Note that holding a reference to a device does not prevent its regmap
> > from going away so there is no point in keeping the reference.

> > Fixes: 0b7c6075022c ("soc: samsung: exynos-pmu: Add regmap support for SoCs that protect PMU regs")
> > Cc: stable@vger.kernel.org	# 6.9
> 
> Fix is fine, but unfortunately the code in v6.9 was different and I
> believe keeping dev reference made sense there - driver was relying on
> drvdata. While the leak was there as well, it was intentional. I think
> the leak can be fixed only since commit
> 35d6b98c625867209bc47df99cf03edf4280799f .

It makes no difference actually as holding a reference to a device does
not prevent its driver data from going away either.

Johan

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

* Re: [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup
  2025-11-21 15:03   ` Johan Hovold
@ 2025-11-27 15:55     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-27 15:55 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Alim Akhtar, Peter Griffin, linux-samsung-soc, linux-kernel,
	stable

On 21/11/2025 16:03, Johan Hovold wrote:
> On Fri, Nov 21, 2025 at 01:59:59PM +0100, Krzysztof Kozlowski wrote:
>> On 21/11/2025 13:18, Johan Hovold wrote:
>>> Make sure to drop the reference taken when looking up the PMU device and
>>> its regmap.
>>>
>>> Note that holding a reference to a device does not prevent its regmap
>>> from going away so there is no point in keeping the reference.
> 
>>> Fixes: 0b7c6075022c ("soc: samsung: exynos-pmu: Add regmap support for SoCs that protect PMU regs")
>>> Cc: stable@vger.kernel.org	# 6.9
>>
>> Fix is fine, but unfortunately the code in v6.9 was different and I
>> believe keeping dev reference made sense there - driver was relying on
>> drvdata. While the leak was there as well, it was intentional. I think
>> the leak can be fixed only since commit
>> 35d6b98c625867209bc47df99cf03edf4280799f .
> 
> It makes no difference actually as holding a reference to a device does
> not prevent its driver data from going away either.

True, fair enough.

Best regards,
Krzysztof

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

* Re: [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup
  2025-11-21 12:18 [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup Johan Hovold
  2025-11-21 12:59 ` Krzysztof Kozlowski
@ 2025-11-27 15:56 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-27 15:56 UTC (permalink / raw)
  To: Alim Akhtar, Johan Hovold
  Cc: Krzysztof Kozlowski, Peter Griffin, linux-samsung-soc,
	linux-kernel, stable


On Fri, 21 Nov 2025 13:18:52 +0100, Johan Hovold wrote:
> Make sure to drop the reference taken when looking up the PMU device and
> its regmap.
> 
> Note that holding a reference to a device does not prevent its regmap
> from going away so there is no point in keeping the reference.
> 
> 
> [...]

Applied for late. I might send it during merge window or might miss it and roll
for the next one. In any case I will keep it in my tree.

Applied, thanks!

[1/1] soc: samsung: exynos-pmu: fix device leak on regmap lookup
      https://git.kernel.org/krzk/linux/c/990eb9a8eb4540ab90c7b34bb07b87ff13881cad

Best regards,
-- 
Krzysztof Kozlowski <krzk@kernel.org>

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

end of thread, other threads:[~2025-11-27 15:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 12:18 [PATCH] soc: samsung: exynos-pmu: fix device leak on regmap lookup Johan Hovold
2025-11-21 12:59 ` Krzysztof Kozlowski
2025-11-21 15:03   ` Johan Hovold
2025-11-27 15:55     ` Krzysztof Kozlowski
2025-11-27 15:56 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox