* [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors
@ 2026-07-13 17:16 Alfie Varghese
2026-07-13 17:26 ` sashiko-bot
2026-07-14 7:06 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Alfie Varghese @ 2026-07-13 17:16 UTC (permalink / raw)
To: neil.armstrong, gregkh
Cc: linux-media, linux-amlogic, linux-staging, linux-kernel,
Alfie Varghese
vdec_probe() maps any devm_clk_get() failure to -EPROBE_DEFER. This is
incorrect because devm_clk_get() can fail with other error codes like
-ENOMEM or -ENOENT (clock not registered). Hardcoding -EPROBE_DEFER
masks these real errors, causing the driver core to retry probing
indefinitely instead of failing early.
Propagate the actual error value using PTR_ERR() instead.
Signed-off-by: Alfie Varghese <alfievarghese22@gmail.com>
---
drivers/staging/media/meson/vdec/vdec.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
index a039d925c0fe..fba1e7f88d81 100644
--- a/drivers/staging/media/meson/vdec/vdec.c
+++ b/drivers/staging/media/meson/vdec/vdec.c
@@ -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)
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors
2026-07-13 17:16 [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors Alfie Varghese
@ 2026-07-13 17:26 ` sashiko-bot
2026-07-14 7:06 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-07-13 17:26 UTC (permalink / raw)
To: Alfie Varghese; +Cc: linux-amlogic, neil.armstrong
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The asynchronous worker `esparser_queue_work` is scheduled but never explicitly canceled, leading to a Use-After-Free when the file descriptor is closed.
- [High] Potential NULL pointer dereference when accessing `of_id->data` if `of_match_node()` returns NULL.
- [High] Missing cleanup of V4L2 control handler in the session release path causes a memory leak.
- [High] Early IRQ request allows spurious or pending interrupts to dereference a NULL `core->cur_sess`.
--
--- Patch [1]: [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors ---
commit e254e1429efee5a0b94f582e6b31b4ef82669c9a
Author: Alfie Varghese <alfievarghese22@gmail.com>
staging: media: meson: vdec: propagate devm_clk_get() errors
This commit modifies vdec_probe() to propagate actual error codes returned
by devm_clk_get() instead of hardcoding -EPROBE_DEFER. It prevents the
driver core from retrying probes indefinitely when encountering real
errors like -ENOMEM or -ENOENT.
> diff --git a/drivers/staging/media/meson/vdec/vdec.c b/drivers/staging/media/meson/vdec/vdec.c
> index a039d925c0fe5..fba1e7f88d81f 100644
> --- a/drivers/staging/media/meson/vdec/vdec.c
> +++ b/drivers/staging/media/meson/vdec/vdec.c
> @@ -1026,24 +1026,24 @@ static int vdec_probe(struct platform_device *pdev)
[Severity: High]
This is a pre-existing issue, but does this code handle the case where
of_match_node() returns NULL? If the driver is bound manually via sysfs
to a platform device lacking a device tree node, of_match_node()
returns NULL.
drivers/staging/media/meson/vdec/vdec.c:vdec_probe() {
...
of_id = of_match_node(vdec_dt_match, dev->of_node);
core->platform = of_id->data;
...
}
Could this lead to a NULL pointer dereference when accessing of_id->data?
> 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->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 is it safe to request the IRQ before
the session state is initialized?
drivers/staging/media/meson/vdec/vdec.c:vdec_probe() {
...
ret = devm_request_threaded_irq(core->dev, irq, vdec_isr,
vdec_threaded_isr, IRQF_ONESHOT,
"vdec", core);
...
}
If a spurious interrupt or a pending interrupt from the bootloader fires
immediately, the ISR dereferences core->cur_sess:
drivers/staging/media/meson/vdec/vdec.c:vdec_isr() {
...
struct amvdec_session *sess = core->cur_sess;
sess->last_irq_jiffies = get_jiffies_64();
...
}
Will this cause a NULL pointer dereference since the session state isn't
established until later?
[Severity: Critical]
This isn't a bug introduced by this patch, but is there a use-after-free
risk when the file descriptor is closed?
If userspace queues a buffer (which schedules sess->esparser_queue_work)
and immediately closes the file descriptor, vdec_close() frees the
session context without syncing:
drivers/staging/media/meson/vdec/vdec.c:vdec_close() {
...
kfree(sess);
...
}
However, the asynchronous worker doesn't appear to be explicitly
canceled with cancel_work_sync(), and might dereference the freed
pointer:
drivers/staging/media/meson/vdec/esparser.c:esparser_queue_all_src() {
...
struct amvdec_session *sess =
container_of(work, struct amvdec_session, esparser_queue_work);
mutex_lock(&sess->lock);
...
}
Can this lead to memory corruption if the worker runs after the release?
[Severity: High]
This is a pre-existing issue, but does vdec_close() properly clean up
the V4L2 control handler?
The handler is initialized via v4l2_ctrl_handler_init() during open,
allocating internal control structures, but vdec_close() seems to omit
the corresponding teardown call before freeing the session context:
drivers/staging/media/meson/vdec/vdec.c:vdec_close() {
...
kfree(sess);
...
}
If an unprivileged user repeatedly opens and closes the device, could
this leak kernel memory and eventually cause an out-of-memory condition?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713171644.691-1-alfievarghese22@gmail.com?part=1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors
2026-07-13 17:16 [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors Alfie Varghese
2026-07-13 17:26 ` sashiko-bot
@ 2026-07-14 7:06 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-07-14 7:06 UTC (permalink / raw)
To: Alfie Varghese
Cc: neil.armstrong, gregkh, linux-media, linux-amlogic, linux-staging,
linux-kernel
On Mon, Jul 13, 2026 at 10:46:44PM +0530, Alfie Varghese wrote:
> vdec_probe() maps any devm_clk_get() failure to -EPROBE_DEFER. This is
> incorrect because devm_clk_get() can fail with other error codes like
> -ENOMEM or -ENOENT (clock not registered). Hardcoding -EPROBE_DEFER
> masks these real errors, causing the driver core to retry probing
> indefinitely instead of failing early.
It will not keep retrying "indefinitely". -EPROBE_DEFER handling
is smarter than that. Fix the misleading commit message and add
a Fixes tag.
regards,
dan carpenter
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-14 7:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 17:16 [PATCH] staging: media: meson: vdec: propagate devm_clk_get() errors Alfie Varghese
2026-07-13 17:26 ` sashiko-bot
2026-07-14 7:06 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox