* [PATCH] video: fbdev: omapfb: Add missing error check for clk_get()
@ 2026-03-10 8:56 Chen Ni
2026-03-10 17:42 ` Helge Deller
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chen Ni @ 2026-03-10 8:56 UTC (permalink / raw)
To: linux-fbdev, linux-omap; +Cc: deller, tglx, mingo, dri-devel, Chen Ni
The hwa742_init() function did not check the return value of clk_get().
This could lead to dereferencing an error pointer in subsequent clock
operations, potentially causing a kernel crash.
Fix this by adding a missing error check and ensuring proper clock
resource cleanup on failure and driver removal.
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
drivers/video/fbdev/omap/hwa742.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/video/fbdev/omap/hwa742.c b/drivers/video/fbdev/omap/hwa742.c
index 64e76e1f5388..68a677f824e9 100644
--- a/drivers/video/fbdev/omap/hwa742.c
+++ b/drivers/video/fbdev/omap/hwa742.c
@@ -950,6 +950,8 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
omapfb_conf = dev_get_platdata(fbdev->dev);
hwa742.sys_ck = clk_get(NULL, "hwa_sys_ck");
+ if (IS_ERR(hwa742.sys_ck))
+ return PTR_ERR(hwa742.sys_ck);
spin_lock_init(&hwa742.req_lock);
@@ -1028,6 +1030,7 @@ static int hwa742_init(struct omapfb_device *fbdev, int ext_mode,
err2:
hwa742.int_ctrl->cleanup();
err1:
+ clk_put(hwa742.sys_ck);
return r;
}
@@ -1037,6 +1040,7 @@ static void hwa742_cleanup(void)
hwa742.extif->cleanup();
hwa742.int_ctrl->cleanup();
clk_disable_unprepare(hwa742.sys_ck);
+ clk_put(hwa742.sys_ck);
}
struct lcd_ctrl hwa742_ctrl = {
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] video: fbdev: omapfb: Add missing error check for clk_get()
2026-03-10 8:56 [PATCH] video: fbdev: omapfb: Add missing error check for clk_get() Chen Ni
@ 2026-03-10 17:42 ` Helge Deller
2026-03-11 3:28 ` Claude review: " Claude Code Review Bot
2026-03-11 3:28 ` Claude Code Review Bot
2 siblings, 0 replies; 4+ messages in thread
From: Helge Deller @ 2026-03-10 17:42 UTC (permalink / raw)
To: Chen Ni, linux-fbdev, linux-omap; +Cc: tglx, mingo, dri-devel
On 3/10/26 09:56, Chen Ni wrote:
> The hwa742_init() function did not check the return value of clk_get().
> This could lead to dereferencing an error pointer in subsequent clock
> operations, potentially causing a kernel crash.
>
> Fix this by adding a missing error check and ensuring proper clock
> resource cleanup on failure and driver removal.
>
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
> drivers/video/fbdev/omap/hwa742.c | 4 ++++
> 1 file changed, 4 insertions(+)
applied.
Thanks!
Helge
^ permalink raw reply [flat|nested] 4+ messages in thread
* Claude review: video: fbdev: omapfb: Add missing error check for clk_get()
2026-03-10 8:56 [PATCH] video: fbdev: omapfb: Add missing error check for clk_get() Chen Ni
2026-03-10 17:42 ` Helge Deller
@ 2026-03-11 3:28 ` Claude Code Review Bot
2026-03-11 3:28 ` Claude Code Review Bot
2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-03-11 3:28 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: video: fbdev: omapfb: Add missing error check for clk_get()
Author: Chen Ni <nichen@iscas.ac.cn>
Patches: 2
Reviewed: 2026-03-11T13:28:19.231251
---
This is a single-patch series adding a missing error check for `clk_get()` in the OMAP HWA742 fbdev driver. The bug is real — `clk_get()` can return an error pointer, and the current code blindly passes it to `clk_get_rate()`, `clk_prepare_enable()`, etc., which would dereference the error pointer and crash the kernel. The fix is straightforward and mostly correct, though it has one issue with the error path cleanup.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Claude review: video: fbdev: omapfb: Add missing error check for clk_get()
2026-03-10 8:56 [PATCH] video: fbdev: omapfb: Add missing error check for clk_get() Chen Ni
2026-03-10 17:42 ` Helge Deller
2026-03-11 3:28 ` Claude review: " Claude Code Review Bot
@ 2026-03-11 3:28 ` Claude Code Review Bot
2 siblings, 0 replies; 4+ messages in thread
From: Claude Code Review Bot @ 2026-03-11 3:28 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**The IS_ERR check is correct and needed.** The `clk_get()` call at line 952 is indeed unchecked, and adding the check is the right thing to do:
```c
hwa742.sys_ck = clk_get(NULL, "hwa_sys_ck");
+ if (IS_ERR(hwa742.sys_ck))
+ return PTR_ERR(hwa742.sys_ck);
```
This is fine — at this point in `hwa742_init()`, no resources have been acquired yet (the `int_ctrl->init()` and `extif->init()` calls happen later), so returning directly is correct rather than going through the error unwind labels.
**The `clk_put()` in `err1` is problematic.** Looking at the error paths:
```c
err1:
+ clk_put(hwa742.sys_ck);
return r;
```
The `err1` label is reached from line 956-957:
```c
if ((r = hwa742.int_ctrl->init(fbdev, 1, req_vram)) < 0)
goto err1;
```
And also falls through from `err2`:
```c
err2:
hwa742.int_ctrl->cleanup();
err1:
+ clk_put(hwa742.sys_ck);
return r;
```
Since `clk_get()` succeeded if we reach any of these labels (the IS_ERR check returns early), calling `clk_put()` at `err1` is correct. Similarly, `err3` and `err4` flow through `err2` → `err1`, so all error paths will now properly release the clock. This is actually fine.
**The `clk_put()` in `hwa742_cleanup()` is correct:**
```c
clk_disable_unprepare(hwa742.sys_ck);
+ clk_put(hwa742.sys_ck);
```
The clock needs to be released on driver cleanup. The ordering (disable/unprepare first, then put) is correct.
**Minor observation:** This driver uses the legacy `clk_get(NULL, ...)` / `clk_put()` API rather than `devm_clk_get()`. Converting to the managed API would be a further improvement but is outside the scope of this fix and would be a separate cleanup patch.
**Overall:** The patch is correct and addresses a real bug. The error handling and cleanup are properly structured.
Reviewed-by looks appropriate for this patch.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-11 3:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-10 8:56 [PATCH] video: fbdev: omapfb: Add missing error check for clk_get() Chen Ni
2026-03-10 17:42 ` Helge Deller
2026-03-11 3:28 ` Claude review: " Claude Code Review Bot
2026-03-11 3:28 ` Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox