* [PATCH] drm/imx/tve: fix probe device leak
@ 2025-09-23 15:13 Johan Hovold
2025-09-23 19:26 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Johan Hovold @ 2025-09-23 15:13 UTC (permalink / raw)
To: Philipp Zabel
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, dri-devel, imx, linux-kernel, Johan Hovold, stable
Make sure to drop the reference taken to the DDC device during probe on
probe failure (e.g. probe deferral) and on driver unbind.
Fixes: fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")
Cc: stable@vger.kernel.org # 3.10
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/gpu/drm/imx/ipuv3/imx-tve.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/imx/ipuv3/imx-tve.c b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
index c5629e155d25..895413d26113 100644
--- a/drivers/gpu/drm/imx/ipuv3/imx-tve.c
+++ b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
@@ -525,6 +525,13 @@ static const struct component_ops imx_tve_ops = {
.bind = imx_tve_bind,
};
+static void imx_tve_put_device(void *_dev)
+{
+ struct device *dev = _dev;
+
+ put_device(dev);
+}
+
static int imx_tve_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)
if (ddc_node) {
tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
of_node_put(ddc_node);
+
+ ret = devm_add_action_or_reset(dev, imx_tve_put_device,
+ &tve->ddc->dev);
+ if (ret)
+ return ret;
}
tve->mode = of_get_tve_mode(np);
--
2.49.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] drm/imx/tve: fix probe device leak
2025-09-23 15:13 [PATCH] drm/imx/tve: fix probe device leak Johan Hovold
@ 2025-09-23 19:26 ` Frank Li
2025-10-27 13:36 ` Johan Hovold
2025-10-30 15:27 ` Philipp Zabel
2 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2025-09-23 19:26 UTC (permalink / raw)
To: Johan Hovold
Cc: Philipp Zabel, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel, imx,
linux-kernel, stable
On Tue, Sep 23, 2025 at 05:13:46PM +0200, Johan Hovold wrote:
> Make sure to drop the reference taken to the DDC device during probe on
> probe failure (e.g. probe deferral) and on driver unbind.
>
> Fixes: fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")
> Cc: stable@vger.kernel.org # 3.10
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/gpu/drm/imx/ipuv3/imx-tve.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/imx/ipuv3/imx-tve.c b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
> index c5629e155d25..895413d26113 100644
> --- a/drivers/gpu/drm/imx/ipuv3/imx-tve.c
> +++ b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
> @@ -525,6 +525,13 @@ static const struct component_ops imx_tve_ops = {
> .bind = imx_tve_bind,
> };
>
> +static void imx_tve_put_device(void *_dev)
> +{
> + struct device *dev = _dev;
> +
> + put_device(dev);
> +}
> +
> static int imx_tve_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)
> if (ddc_node) {
> tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
> of_node_put(ddc_node);
> +
> + ret = devm_add_action_or_reset(dev, imx_tve_put_device,
> + &tve->ddc->dev);
> + if (ret)
> + return ret;
> }
>
> tve->mode = of_get_tve_mode(np);
> --
> 2.49.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drm/imx/tve: fix probe device leak
2025-09-23 15:13 [PATCH] drm/imx/tve: fix probe device leak Johan Hovold
2025-09-23 19:26 ` Frank Li
@ 2025-10-27 13:36 ` Johan Hovold
2025-10-30 15:27 ` Philipp Zabel
2 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2025-10-27 13:36 UTC (permalink / raw)
To: Philipp Zabel
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, dri-devel, imx, linux-kernel, stable
On Tue, Sep 23, 2025 at 05:13:46PM +0200, Johan Hovold wrote:
> Make sure to drop the reference taken to the DDC device during probe on
> probe failure (e.g. probe deferral) and on driver unbind.
>
> Fixes: fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")
> Cc: stable@vger.kernel.org # 3.10
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
Can this one be picked up for 6.19?
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drm/imx/tve: fix probe device leak
2025-09-23 15:13 [PATCH] drm/imx/tve: fix probe device leak Johan Hovold
2025-09-23 19:26 ` Frank Li
2025-10-27 13:36 ` Johan Hovold
@ 2025-10-30 15:27 ` Philipp Zabel
2025-10-30 16:36 ` Johan Hovold
2 siblings, 1 reply; 5+ messages in thread
From: Philipp Zabel @ 2025-10-30 15:27 UTC (permalink / raw)
To: Johan Hovold
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, dri-devel, imx, linux-kernel, stable
On Di, 2025-09-23 at 17:13 +0200, Johan Hovold wrote:
> Make sure to drop the reference taken to the DDC device during probe on
> probe failure (e.g. probe deferral) and on driver unbind.
>
> Fixes: fcbc51e54d2a ("staging: drm/imx: Add support for Television Encoder (TVEv2)")
> Cc: stable@vger.kernel.org # 3.10
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/gpu/drm/imx/ipuv3/imx-tve.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/imx/ipuv3/imx-tve.c b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
> index c5629e155d25..895413d26113 100644
> --- a/drivers/gpu/drm/imx/ipuv3/imx-tve.c
> +++ b/drivers/gpu/drm/imx/ipuv3/imx-tve.c
> @@ -525,6 +525,13 @@ static const struct component_ops imx_tve_ops = {
> .bind = imx_tve_bind,
> };
>
> +static void imx_tve_put_device(void *_dev)
> +{
> + struct device *dev = _dev;
> +
> + put_device(dev);
> +}
> +
> static int imx_tve_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)
> if (ddc_node) {
> tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
> of_node_put(ddc_node);
> +
> + ret = devm_add_action_or_reset(dev, imx_tve_put_device,
> + &tve->ddc->dev);
I think this needs to be wrapped in "if (tve->ddc) { }",
of_find_i2c_adapter_by_node() can return NULL.
regards
Philipp
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drm/imx/tve: fix probe device leak
2025-10-30 15:27 ` Philipp Zabel
@ 2025-10-30 16:36 ` Johan Hovold
0 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2025-10-30 16:36 UTC (permalink / raw)
To: Philipp Zabel
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, dri-devel, imx, linux-kernel, stable
On Thu, Oct 30, 2025 at 04:27:39PM +0100, Philipp Zabel wrote:
> On Di, 2025-09-23 at 17:13 +0200, Johan Hovold wrote:
> > static int imx_tve_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > @@ -546,6 +553,11 @@ static int imx_tve_probe(struct platform_device *pdev)
> > if (ddc_node) {
> > tve->ddc = of_find_i2c_adapter_by_node(ddc_node);
> > of_node_put(ddc_node);
> > +
> > + ret = devm_add_action_or_reset(dev, imx_tve_put_device,
> > + &tve->ddc->dev);
>
> I think this needs to be wrapped in "if (tve->ddc) { }",
> of_find_i2c_adapter_by_node() can return NULL.
Indeed, thanks for catching that. Just sent a v2.
Johan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-30 16:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 15:13 [PATCH] drm/imx/tve: fix probe device leak Johan Hovold
2025-09-23 19:26 ` Frank Li
2025-10-27 13:36 ` Johan Hovold
2025-10-30 15:27 ` Philipp Zabel
2025-10-30 16:36 ` Johan Hovold
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).