* [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup
@ 2025-09-26 14:24 Johan Hovold
2025-09-26 14:24 ` [PATCH 1/2] " Johan Hovold
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Johan Hovold @ 2025-09-26 14:24 UTC (permalink / raw)
To: Neil Armstrong, Kevin Hilman
Cc: Jerome Brunet, Martin Blumenstingl, linux-amlogic, linux-kernel,
Johan Hovold
This series fixes a device leak in the canvas lookup helper and
simplifies the lookup error handling somewhat.
Johan
Johan Hovold (2):
soc: amlogic: canvas: fix device leak on lookup
soc: amlogic: canvas: simplify lookup error handling
drivers/soc/amlogic/meson-canvas.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
--
2.49.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] soc: amlogic: canvas: fix device leak on lookup
2025-09-26 14:24 [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Johan Hovold
@ 2025-09-26 14:24 ` Johan Hovold
2025-09-26 19:15 ` Markus Elfring
2025-10-04 19:52 ` Martin Blumenstingl
2025-09-26 14:24 ` [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling Johan Hovold
2025-10-21 12:29 ` [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Neil Armstrong
2 siblings, 2 replies; 8+ messages in thread
From: Johan Hovold @ 2025-09-26 14:24 UTC (permalink / raw)
To: Neil Armstrong, Kevin Hilman
Cc: Jerome Brunet, Martin Blumenstingl, linux-amlogic, linux-kernel,
Johan Hovold, stable, Yu Kuai
Make sure to drop the reference taken to the canvas platform device when
looking up its driver data.
Note that holding a reference to a device does not prevent its driver
data from going away so there is no point in keeping the reference.
Also note that commit 28f851e6afa8 ("soc: amlogic: canvas: add missing
put_device() call in meson_canvas_get()") fixed the leak in a lookup
error path, but the reference is still leaking on success.
Fixes: d4983983d987 ("soc: amlogic: add meson-canvas driver")
Cc: stable@vger.kernel.org # 4.20: 28f851e6afa8
Cc: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/soc/amlogic/meson-canvas.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/amlogic/meson-canvas.c b/drivers/soc/amlogic/meson-canvas.c
index b6e06c4d2117..0711088da5dc 100644
--- a/drivers/soc/amlogic/meson-canvas.c
+++ b/drivers/soc/amlogic/meson-canvas.c
@@ -73,10 +73,9 @@ struct meson_canvas *meson_canvas_get(struct device *dev)
* current state, this driver probe cannot return -EPROBE_DEFER
*/
canvas = dev_get_drvdata(&canvas_pdev->dev);
- if (!canvas) {
- put_device(&canvas_pdev->dev);
+ put_device(&canvas_pdev->dev);
+ if (!canvas)
return ERR_PTR(-EINVAL);
- }
return canvas;
}
--
2.49.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling
2025-09-26 14:24 [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Johan Hovold
2025-09-26 14:24 ` [PATCH 1/2] " Johan Hovold
@ 2025-09-26 14:24 ` Johan Hovold
2025-09-26 19:18 ` Markus Elfring
2025-10-04 19:53 ` Martin Blumenstingl
2025-10-21 12:29 ` [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Neil Armstrong
2 siblings, 2 replies; 8+ messages in thread
From: Johan Hovold @ 2025-09-26 14:24 UTC (permalink / raw)
To: Neil Armstrong, Kevin Hilman
Cc: Jerome Brunet, Martin Blumenstingl, linux-amlogic, linux-kernel,
Johan Hovold
Simplify the canvas lookup error handling by dropping the OF node
reference sooner.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/soc/amlogic/meson-canvas.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/soc/amlogic/meson-canvas.c b/drivers/soc/amlogic/meson-canvas.c
index 0711088da5dc..79681afea8c6 100644
--- a/drivers/soc/amlogic/meson-canvas.c
+++ b/drivers/soc/amlogic/meson-canvas.c
@@ -60,12 +60,9 @@ struct meson_canvas *meson_canvas_get(struct device *dev)
return ERR_PTR(-ENODEV);
canvas_pdev = of_find_device_by_node(canvas_node);
- if (!canvas_pdev) {
- of_node_put(canvas_node);
- return ERR_PTR(-EPROBE_DEFER);
- }
-
of_node_put(canvas_node);
+ if (!canvas_pdev)
+ return ERR_PTR(-EPROBE_DEFER);
/*
* If priv is NULL, it's probably because the canvas hasn't
--
2.49.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] soc: amlogic: canvas: fix device leak on lookup
2025-09-26 14:24 ` [PATCH 1/2] " Johan Hovold
@ 2025-09-26 19:15 ` Markus Elfring
2025-10-04 19:52 ` Martin Blumenstingl
1 sibling, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2025-09-26 19:15 UTC (permalink / raw)
To: Johan Hovold, linux-amlogic, Kevin Hilman, Neil Armstrong
Cc: stable, LKML, Jerome Brunet, Martin Blumenstingl, Yu Kuai
> Make sure to drop the reference taken to the canvas platform device when
> looking up its driver data.
…
How do you think about to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/device.h#L1180
Regards,
Markus
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling
2025-09-26 14:24 ` [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling Johan Hovold
@ 2025-09-26 19:18 ` Markus Elfring
2025-10-04 19:53 ` Martin Blumenstingl
1 sibling, 0 replies; 8+ messages in thread
From: Markus Elfring @ 2025-09-26 19:18 UTC (permalink / raw)
To: Johan Hovold, linux-amlogic, Kevin Hilman, Neil Armstrong
Cc: stable, LKML, Jerome Brunet, Martin Blumenstingl, Yu Kuai
> Simplify the canvas lookup error handling by dropping the OF node
> reference sooner.
How do you think about to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/of.h#L138
Regards,
Markus
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] soc: amlogic: canvas: fix device leak on lookup
2025-09-26 14:24 ` [PATCH 1/2] " Johan Hovold
2025-09-26 19:15 ` Markus Elfring
@ 2025-10-04 19:52 ` Martin Blumenstingl
1 sibling, 0 replies; 8+ messages in thread
From: Martin Blumenstingl @ 2025-10-04 19:52 UTC (permalink / raw)
To: Johan Hovold
Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, linux-amlogic,
linux-kernel, stable, Yu Kuai, Markus.Elfring
On Fri, Sep 26, 2025 at 4:25 PM Johan Hovold <johan@kernel.org> wrote:
>
> Make sure to drop the reference taken to the canvas platform device when
> looking up its driver data.
>
> Note that holding a reference to a device does not prevent its driver
> data from going away so there is no point in keeping the reference.
>
> Also note that commit 28f851e6afa8 ("soc: amlogic: canvas: add missing
> put_device() call in meson_canvas_get()") fixed the leak in a lookup
> error path, but the reference is still leaking on success.
>
> Fixes: d4983983d987 ("soc: amlogic: add meson-canvas driver")
> Cc: stable@vger.kernel.org # 4.20: 28f851e6afa8
> Cc: Yu Kuai <yukuai3@huawei.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
I haven't used the scope-based resource management myself as pointed
out by Markus.
That said, as far as I understand it's a feature in newer kernels and
this patch may be backported until 5.4 (oldest -stable kernel still
supported).
So let's go with this simple approach from Johan - we can still
improve this (without having to worry about backports).
Best regards,
Martin
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling
2025-09-26 14:24 ` [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling Johan Hovold
2025-09-26 19:18 ` Markus Elfring
@ 2025-10-04 19:53 ` Martin Blumenstingl
1 sibling, 0 replies; 8+ messages in thread
From: Martin Blumenstingl @ 2025-10-04 19:53 UTC (permalink / raw)
To: Johan Hovold
Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, linux-amlogic,
linux-kernel
On Fri, Sep 26, 2025 at 4:25 PM Johan Hovold <johan@kernel.org> wrote:
>
> Simplify the canvas lookup error handling by dropping the OF node
> reference sooner.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup
2025-09-26 14:24 [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Johan Hovold
2025-09-26 14:24 ` [PATCH 1/2] " Johan Hovold
2025-09-26 14:24 ` [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling Johan Hovold
@ 2025-10-21 12:29 ` Neil Armstrong
2 siblings, 0 replies; 8+ messages in thread
From: Neil Armstrong @ 2025-10-21 12:29 UTC (permalink / raw)
To: Kevin Hilman, Johan Hovold
Cc: Jerome Brunet, Martin Blumenstingl, linux-amlogic, linux-kernel
Hi,
On Fri, 26 Sep 2025 16:24:52 +0200, Johan Hovold wrote:
> This series fixes a device leak in the canvas lookup helper and
> simplifies the lookup error handling somewhat.
>
> Johan
>
>
> Johan Hovold (2):
> soc: amlogic: canvas: fix device leak on lookup
> soc: amlogic: canvas: simplify lookup error handling
>
> [...]
Thanks, Applied to https://git.kernel.org/pub/scm/linux/kernel/git/amlogic/linux.git (v6.19/drivers)
[1/2] soc: amlogic: canvas: fix device leak on lookup
https://git.kernel.org/amlogic/c/32200f4828de9d7e6db379909898e718747f4e18
[2/2] soc: amlogic: canvas: simplify lookup error handling
https://git.kernel.org/amlogic/c/075daf22641870e435a16ec2129bfd3b3134c487
These changes has been applied on the intermediate git tree [1].
The v6.19/drivers branch will then be sent via a formal Pull Request to the Linux SoC maintainers
for inclusion in their intermediate git branches in order to be sent to Linus during
the next merge window, or sooner if it's a set of fixes.
In the cases of fixes, those will be merged in the current release candidate
kernel and as soon they appear on the Linux master branch they will be
backported to the previous Stable and Long-Stable kernels [2].
The intermediate git branches are merged daily in the linux-next tree [3],
people are encouraged testing these pre-release kernels and report issues on the
relevant mailing-lists.
If problems are discovered on those changes, please submit a signed-off-by revert
patch followed by a corrective changeset.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/amlogic/linux.git
[2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
[3] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
--
Neil
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-10-21 12:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-26 14:24 [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Johan Hovold
2025-09-26 14:24 ` [PATCH 1/2] " Johan Hovold
2025-09-26 19:15 ` Markus Elfring
2025-10-04 19:52 ` Martin Blumenstingl
2025-09-26 14:24 ` [PATCH 2/2] soc: amlogic: canvas: simplify lookup error handling Johan Hovold
2025-09-26 19:18 ` Markus Elfring
2025-10-04 19:53 ` Martin Blumenstingl
2025-10-21 12:29 ` [PATCH 0/2] soc: amlogic: canvas: fix device leak on lookup Neil Armstrong
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).