* [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe
@ 2025-10-28 10:04 Johan Hovold
2025-10-28 10:04 ` [PATCH v2 1/2] media: mediatek: mdp: fix device leak " Johan Hovold
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Johan Hovold @ 2025-10-28 10:04 UTC (permalink / raw)
To: Minghsiu Tsai, Houlong Wei, Andrew-CT Chen
Cc: Mauro Carvalho Chehab, Matthias Brugger,
AngeloGioacchino Del Regno, Tiffany Lin, Yunfei Dong,
Nicolas Dufresne, linux-media, linux-mediatek, linux-kernel,
Johan Hovold
This series fixes VPU device leaks during probe of the mdp driver.
Included is also a minor documentation update to make it clear that the
VPU lookup helper returns the device with an incremented refcount.
Johan
Changes in v2
- drop incorrect vcodec patch since that reference leak has already
been fixed by commit bf1d556ad4e0 ("media: mtk-vcodec: abstract
firmware interface") which added the codec release callback
Johan Hovold (2):
media: mediatek: mdp: fix device leak on probe
media: mediatek: amend vpu_get_plat_device() documentation
drivers/media/platform/mediatek/mdp/mtk_mdp_core.c | 7 +++++--
drivers/media/platform/mediatek/vpu/mtk_vpu.h | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] media: mediatek: mdp: fix device leak on probe
2025-10-28 10:04 [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
@ 2025-10-28 10:04 ` Johan Hovold
2025-10-28 10:04 ` [PATCH v2 2/2] media: mediatek: amend vpu_get_plat_device() documentation Johan Hovold
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-10-28 10:04 UTC (permalink / raw)
To: Minghsiu Tsai, Houlong Wei, Andrew-CT Chen
Cc: Mauro Carvalho Chehab, Matthias Brugger,
AngeloGioacchino Del Regno, Tiffany Lin, Yunfei Dong,
Nicolas Dufresne, linux-media, linux-mediatek, linux-kernel,
Johan Hovold, stable
Make sure to drop the reference taken when looking up the VPU firmware
device during probe on probe failure (e.g. probe deferral) and on driver
unbind.
Fixes: c8eb2d7e8202 ("[media] media: Add Mediatek MDP Driver")
Cc: stable@vger.kernel.org # 4.10
Cc: Minghsiu Tsai <minghsiu.tsai@mediatek.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/media/platform/mediatek/mdp/mtk_mdp_core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/mediatek/mdp/mtk_mdp_core.c b/drivers/media/platform/mediatek/mdp/mtk_mdp_core.c
index 80fdc6ff57e0..5c7dcf4090f4 100644
--- a/drivers/media/platform/mediatek/mdp/mtk_mdp_core.c
+++ b/drivers/media/platform/mediatek/mdp/mtk_mdp_core.c
@@ -198,7 +198,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
VPU_RST_MDP);
if (ret) {
dev_err(&pdev->dev, "Failed to register reset handler\n");
- goto err_m2m_register;
+ goto err_put_vpu;
}
platform_set_drvdata(pdev, mdp);
@@ -206,7 +206,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)
ret = vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pdev->dev, "Failed to set vb2 dma mag seg size\n");
- goto err_m2m_register;
+ goto err_put_vpu;
}
pm_runtime_enable(dev);
@@ -214,6 +214,8 @@ static int mtk_mdp_probe(struct platform_device *pdev)
return 0;
+err_put_vpu:
+ put_device(&mdp->vpu_dev->dev);
err_m2m_register:
v4l2_device_unregister(&mdp->v4l2_dev);
@@ -241,6 +243,7 @@ static void mtk_mdp_remove(struct platform_device *pdev)
struct mtk_mdp_comp *comp, *comp_temp;
pm_runtime_disable(&pdev->dev);
+ put_device(&mdp->vpu_dev->dev);
vb2_dma_contig_clear_max_seg_size(&pdev->dev);
mtk_mdp_unregister_m2m_device(mdp);
v4l2_device_unregister(&mdp->v4l2_dev);
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] media: mediatek: amend vpu_get_plat_device() documentation
2025-10-28 10:04 [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
2025-10-28 10:04 ` [PATCH v2 1/2] media: mediatek: mdp: fix device leak " Johan Hovold
@ 2025-10-28 10:04 ` Johan Hovold
2025-11-05 8:07 ` [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-10-28 10:04 UTC (permalink / raw)
To: Minghsiu Tsai, Houlong Wei, Andrew-CT Chen
Cc: Mauro Carvalho Chehab, Matthias Brugger,
AngeloGioacchino Del Regno, Tiffany Lin, Yunfei Dong,
Nicolas Dufresne, linux-media, linux-mediatek, linux-kernel,
Johan Hovold
Add a comment to the vpu_get_plat_device() documentation to make it
clear that the VPU platform device is returned with an incremented
reference count (which needs to be dropped after use).
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/media/platform/mediatek/vpu/mtk_vpu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.h b/drivers/media/platform/mediatek/vpu/mtk_vpu.h
index da05f3e74081..5808311d2b15 100644
--- a/drivers/media/platform/mediatek/vpu/mtk_vpu.h
+++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.h
@@ -120,7 +120,7 @@ int vpu_ipi_send(struct platform_device *pdev,
* device for using VPU API.
*
* Return: Return NULL if it is failed.
- * otherwise it is VPU's platform device
+ * otherwise it is VPU's platform device with incremented reference count
**/
struct platform_device *vpu_get_plat_device(struct platform_device *pdev);
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe
2025-10-28 10:04 [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
2025-10-28 10:04 ` [PATCH v2 1/2] media: mediatek: mdp: fix device leak " Johan Hovold
2025-10-28 10:04 ` [PATCH v2 2/2] media: mediatek: amend vpu_get_plat_device() documentation Johan Hovold
@ 2025-11-05 8:07 ` Johan Hovold
2025-11-05 12:31 ` AngeloGioacchino Del Regno
2025-11-20 13:14 ` Johan Hovold
4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-11-05 8:07 UTC (permalink / raw)
To: Minghsiu Tsai, Houlong Wei, Andrew-CT Chen
Cc: Mauro Carvalho Chehab, Matthias Brugger,
AngeloGioacchino Del Regno, Tiffany Lin, Yunfei Dong,
Nicolas Dufresne, linux-media, linux-mediatek, linux-kernel,
Chen-Yu Tsai
On Tue, Oct 28, 2025 at 11:04:52AM +0100, Johan Hovold wrote:
> This series fixes VPU device leaks during probe of the mdp driver.
>
> Included is also a minor documentation update to make it clear that the
> VPU lookup helper returns the device with an incremented refcount.
>
> Johan
>
>
> Changes in v2
> - drop incorrect vcodec patch since that reference leak has already
> been fixed by commit bf1d556ad4e0 ("media: mtk-vcodec: abstract
> firmware interface") which added the codec release callback
>
>
> Johan Hovold (2):
> media: mediatek: mdp: fix device leak on probe
> media: mediatek: amend vpu_get_plat_device() documentation
Looks like I forgot to add Chen-Yu's reviewed-by when respinning:
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe
2025-10-28 10:04 [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
` (2 preceding siblings ...)
2025-11-05 8:07 ` [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
@ 2025-11-05 12:31 ` AngeloGioacchino Del Regno
2025-11-20 13:14 ` Johan Hovold
4 siblings, 0 replies; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-11-05 12:31 UTC (permalink / raw)
To: Johan Hovold, Minghsiu Tsai, Houlong Wei, Andrew-CT Chen
Cc: Mauro Carvalho Chehab, Matthias Brugger, Tiffany Lin, Yunfei Dong,
Nicolas Dufresne, linux-media, linux-mediatek, linux-kernel
Il 28/10/25 11:04, Johan Hovold ha scritto:
> This series fixes VPU device leaks during probe of the mdp driver.
>
> Included is also a minor documentation update to make it clear that the
> VPU lookup helper returns the device with an incremented refcount.
>
> Johan
>
>
> Changes in v2
> - drop incorrect vcodec patch since that reference leak has already
> been fixed by commit bf1d556ad4e0 ("media: mtk-vcodec: abstract
> firmware interface") which added the codec release callback
>
>
> Johan Hovold (2):
> media: mediatek: mdp: fix device leak on probe
> media: mediatek: amend vpu_get_plat_device() documentation
>
> drivers/media/platform/mediatek/mdp/mtk_mdp_core.c | 7 +++++--
> drivers/media/platform/mediatek/vpu/mtk_vpu.h | 2 +-
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
While series is
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe
2025-10-28 10:04 [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
` (3 preceding siblings ...)
2025-11-05 12:31 ` AngeloGioacchino Del Regno
@ 2025-11-20 13:14 ` Johan Hovold
4 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2025-11-20 13:14 UTC (permalink / raw)
To: Minghsiu Tsai, Houlong Wei, Andrew-CT Chen
Cc: Mauro Carvalho Chehab, Matthias Brugger,
AngeloGioacchino Del Regno, Tiffany Lin, Yunfei Dong,
Nicolas Dufresne, linux-media, linux-mediatek, linux-kernel
On Tue, Oct 28, 2025 at 11:04:52AM +0100, Johan Hovold wrote:
> This series fixes VPU device leaks during probe of the mdp driver.
>
> Included is also a minor documentation update to make it clear that the
> VPU lookup helper returns the device with an incremented refcount.
> Changes in v2
> - drop incorrect vcodec patch since that reference leak has already
> been fixed by commit bf1d556ad4e0 ("media: mtk-vcodec: abstract
> firmware interface") which added the codec release callback
>
>
> Johan Hovold (2):
> media: mediatek: mdp: fix device leak on probe
> media: mediatek: amend vpu_get_plat_device() documentation
Can these be picked up for 6.19?
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-20 13:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 10:04 [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
2025-10-28 10:04 ` [PATCH v2 1/2] media: mediatek: mdp: fix device leak " Johan Hovold
2025-10-28 10:04 ` [PATCH v2 2/2] media: mediatek: amend vpu_get_plat_device() documentation Johan Hovold
2025-11-05 8:07 ` [PATCH v2 0/2] media: mediatek: fix VPU device leaks on probe Johan Hovold
2025-11-05 12:31 ` AngeloGioacchino Del Regno
2025-11-20 13:14 ` 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).