staging: media: meson: vdec: propagate devm_clk_get() errors
Subsystems (4)
PATCH v2 1/1 staging: media: meson: vdec: propagate devm_clk_get() errors
vdec_probe() hardcodes -EPROBE_DEFER for all devm_clk_get() failures. This masks the actual error code returned by the clock framework, such as -ENOENT when a clock is not registered or -ENOMEM on allocation failure.
Return PTR_ERR() instead to propagate the real error to the caller.
--- drivers/staging/media/meson/vdec/vdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/media/meson/vdec/vdec.c +5 -5
@@ -1026,24 +1026,24 @@ static int vdec_probe(struct platform_device *pdev) core->platform->revision == VDEC_REVISION_SM1) { core->vdec_hevcf_clk =devm_clk_get (dev,"vdec_hevcf" );if (IS_ERR (core->vdec_hevcf_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_hevcf_clk); } core->dos_parser_clk =devm_clk_get (dev,"dos_parser" );if (IS_ERR (core->dos_parser_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->dos_parser_clk); core->dos_clk =devm_clk_get (dev,"dos" );if (IS_ERR (core->dos_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->dos_clk); core->vdec_1_clk =devm_clk_get (dev,"vdec_1" );if (IS_ERR (core->vdec_1_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_1_clk); core->vdec_hevc_clk =devm_clk_get (dev,"vdec_hevc" );if (IS_ERR (core->vdec_hevc_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_hevc_clk); irq =platform_get_irq_byname (pdev,"vdec" );if (irq <0 )
Signature · 1 line
2.54.0.windows.1
Le mardi 14 juillet 2026 à 19:34 +0530, Alfie Varghese a écrit :
Quoted 9 lines
vdec_probe()hardcodes -EPROBE_DEFER for alldevm_clk_get()failures. This masks the actual error code returned by the clock framework, such as-ENOENTwhen a clock is not registered or-ENOMEMon allocation failure.Return
PTR_ERR()instead to propagate the real error to the caller.Fixes 4f75e7dfa6dc ("media: meson: vdec: add driver")Signed-off-by Alfie Varghese <[email protected]>
Quoted 38 lines
---
drivers/staging/media/meson/vdec/vdec.c | 10 +++++-----1 file changed, 5 insertions(+), 5 deletions(-)drivers/staging/media/meson/vdec/vdec.c +1
-1@@ -1026,24 +1026,24 @@ static int vdec_probe(struct platform_device *pdev) core->platform->revision == VDEC_REVISION_SM1) { core->vdec_hevcf_clk = devm_clk_get(dev, "vdec_hevcf"); if (IS_ERR(core->vdec_hevcf_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_hevcf_clk); }
core->dos_parser_clk=devm_clk_get(dev, "dos_parser"); if (IS_ERR(core->dos_parser_clk))drivers/staging/media/meson/vdec/vdec.c +1
-1-return -EPROBE_DEFER ; +return PTR_ERR (core->dos_parser_clk);
core->dos_clk=devm_clk_get(dev, "dos");
if (IS_ERR(core->dos_clk))drivers/staging/media/meson/vdec/vdec.c +1
-1-return -EPROBE_DEFER ; +return PTR_ERR (core->dos_clk);
core->vdec_1_clk=devm_clk_get(dev, "vdec_1"); if (IS_ERR(core->vdec_1_clk))drivers/staging/media/meson/vdec/vdec.c +1
-1-return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_1_clk);
core->vdec_hevc_clk=devm_clk_get(dev, "vdec_hevc"); if (IS_ERR(core->vdec_hevc_clk))drivers/staging/media/meson/vdec/vdec.c +1
-1-return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_hevc_clk);
irq =platform_get_irq_byname(pdev, "vdec"); if (irq < 0)
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The interrupt handlers vdec_isr and vdec_threaded_isr will dereference a NULL core->cur_sess if triggered early.
- [High] meson_canvas_get() does not establish a device link, leading to a potential Use-After-Free if the canvas driver is unbound. --
--- Patch [1]: [PATCH v2] staging: media: meson: vdec: propagate devm_clk_get() errors --- commit 7a1b822824f968330db11f53c7acb92d01abc7a0
Author: Alfie Varghese <[email protected]>
staging: media: meson: vdec: propagate devm_clk_get() errors
vdec_probe() hardcodes -EPROBE_DEFER for all devm_clk_get() failures. This masks the actual error code returned by the clock framework, such as -ENOENT when a clock is not registered or -ENOMEM on allocation failure.
drivers/staging/media/meson/vdec/vdec.c static int vdec_probe(struct platform_device *pdev)
Quoted 5 lines
drivers/staging/media/meson/vdec/vdec.c +0
-0@@ -1026,24 +1026,24 @@ static int vdec_probe(struct platform_device *pdev)
[Severity: High]
This isn't a bug introduced by this patch, but does the canvas handling risk a use-after-free?
In vdec_probe(), the driver retrieves the canvas provider via meson_canvas_get() slightly earlier in the function. Looking at meson_canvas_get() in meson-canvas.c:
drivers/soc/amlogic/meson-canvas.c:meson_canvas_get() {
...
canvas = dev_get_drvdata(&canvas_pdev->dev);
put_device(&canvas_pdev->dev);
return canvas;
}Since the device reference is dropped immediately before returning and no device link is established using device_link_add(), couldn't a user unbind the amlogic-canvas driver via sysfs, freeing the canvas memory while the active vdec driver still relies on core->canvas?
Quoted 6 lines
drivers/staging/media/meson/vdec/vdec.c +1
-1core->platform->revision == VDEC_REVISION_SM1) { core->vdec_hevcf_clk =devm_clk_get (dev,"vdec_hevcf" );if (IS_ERR (core->vdec_hevcf_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_hevcf_clk); }
[ ... ]
drivers/staging/media/meson/vdec/vdec.c static int vdec_probe(struct platform_device *pdev) · line 1049
Quoted 7 lines
drivers/staging/media/meson/vdec/vdec.c +1
-1core->vdec_hevc_clk =devm_clk_get (dev,"vdec_hevc" );if (IS_ERR (core->vdec_hevc_clk)) -return -EPROBE_DEFER ; +return PTR_ERR (core->vdec_hevc_clk); irq =platform_get_irq_byname (pdev,"vdec" );if (irq <0 )
[Severity: High]
This is a pre-existing issue, but can this code trigger a NULL pointer dereference in the interrupt handler?
Right after retrieving the IRQ in vdec_probe(), the hardware interrupt is registered via devm_request_threaded_irq() before explicitly masking interrupts on the device hardware and before allocating a session.
If the bootloader left the video decoder active, or if a spurious interrupt fires immediately after registration, vdec_isr() would execute:
drivers/staging/media/meson/vdec/vdec.c:vdec_isr() {
...
sess = core->cur_sess;
sess->last_irq_jiffies = get_jiffies_64();
...
}Since core->cur_sess remains NULL until a userspace client opens the device and starts streaming, wouldn't this crash the kernel? Is it possible to disable hardware interrupts prior to IRQ registration, or check for a NULL session in the ISR?
Signature · 6 lines
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 10 lines · Alfie Varghese
vdec_probe()hardcodes -EPROBE_DEFER for alldevm_clk_get()failures. This masks the actual error code returned by the clock framework, such as-ENOENTwhen a clock is not registered or-ENOMEMon allocation failure.Return
PTR_ERR()instead to propagate the real error to the caller.Fixes 4f75e7dfa6dc ("media: meson: vdec: add driver")Signed-off-by Alfie Varghese <[email protected]>---
Thanks!
regards,
dan carpenter