[PATCH v2 2/3] fbdev: pxafb: stop the smart-panel thread
From: Matthias Goergens
Date: Mon Nov 02 2026 - 03:08:21 EST
pxafb_smart_init() starts the smart-panel refresh thread, but nothing
ever stops it: neither pxafb_remove() nor the probe error paths that
run after it. The thread then keeps running on the devm-allocated
struct pxafb_info after it has been freed.
Stop the thread on removal, after pxafb_disable_controller(), which
waits for a refresh that only the thread signals, and on those probe
error paths.
A thread that has already exited must not be passed to kthread_stop()
unless the caller holds a reference to its task_struct (see the comment
above kthread_stop()). This thread returns at once when the board
provides no smart_update callback, so check for the callback in
pxafb_smart_init() before starting the thread. Probe now fails with
-EINVAL in that case, instead of succeeding with a smart panel that is
never refreshed.
This needs CONFIG_FB_PXA_SMARTPANEL and a board with a smart panel; I
found no in-tree board that provides smart_update. Sashiko, the AI
review bot, pointed this out while reviewing a pxafb cleanup. I have
no PXA hardware; this is build-tested only.
Link: https://lore.kernel.org/all/20260722081427.413EF1F000E9@xxxxxxxxxxxxxxx/
Fixes: 3c42a449107b ("pxafb: preliminary smart panel interface support")
Fixes: 9f17f2874834 ("[ARM] 5118/1: pxafb: add exit and remove handlers")
Signed-off-by: Matthias Goergens <matthias.goergens@xxxxxxxxx>
---
drivers/video/fbdev/pxafb.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index 4f5c408eae56..b889a17e7304 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -1248,12 +1248,6 @@ static int pxafb_smart_thread(void *arg)
struct pxafb_info *fbi = arg;
struct pxafb_mach_info *inf = fbi->inf;
- if (!inf->smart_update) {
- pr_err("%s: not properly initialized, thread terminated\n",
- __func__);
- return -EINVAL;
- }
-
pr_debug("%s(): task starting\n", __func__);
set_freezable();
@@ -1290,6 +1284,9 @@ static int pxafb_smart_init(struct pxafb_info *fbi)
init_completion(&fbi->command_done);
init_completion(&fbi->refresh_done);
+ if (!fbi->inf->smart_update)
+ return -EINVAL;
+
fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi,
"lcd_refresh");
if (IS_ERR(fbi->smart_thread)) {
@@ -1299,8 +1296,15 @@ static int pxafb_smart_init(struct pxafb_info *fbi)
return 0;
}
+
+static void pxafb_smart_exit(struct pxafb_info *fbi)
+{
+ if (!IS_ERR_OR_NULL(fbi->smart_thread))
+ kthread_stop(fbi->smart_thread);
+}
#else
static inline int pxafb_smart_init(struct pxafb_info *fbi) { return 0; }
+static inline void pxafb_smart_exit(struct pxafb_info *fbi) { }
#endif /* CONFIG_FB_PXA_SMARTPANEL */
static void setup_parallel_timing(struct pxafb_info *fbi,
@@ -2366,6 +2370,7 @@ static int pxafb_probe(struct platform_device *dev)
if (fbi->fb.cmap.len)
fb_dealloc_cmap(&fbi->fb.cmap);
failed_free_mem:
+ pxafb_smart_exit(fbi);
free_pages_exact(fbi->video_mem, fbi->video_mem_size);
failed_free_dma:
dma_free_coherent(&dev->dev, fbi->dma_buff_size,
@@ -2393,6 +2398,7 @@ static void pxafb_remove(struct platform_device *dev)
unregister_framebuffer(info);
pxafb_disable_controller(fbi);
+ pxafb_smart_exit(fbi);
if (fbi->fb.cmap.len)
fb_dealloc_cmap(&fbi->fb.cmap);
--
2.56.0