Skip to contentSkip to conversation

media: aspeed: disable resolution work before removing the device

PATCH New Myeonghun Pak 1 participant 1 message Oct 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: aspeed: disable resolution work before removing the device

A resolution-change interrupt schedules res_work. The worker enables the video engine clocks, initializes registers and detects the resolution. It can also queue a V4L2 event or restart frame capture. The remove path shuts down the engine and releases resources without cancelling or waiting for this work, so the worker can undo the shutdown or access resources after they have been released.

Disable and drain res_work before turning the engine off. This cancels pending work, waits for a running worker and prevents the IRQ handler from queuing the work again. Keep the clocks and IRQ handler available during the wait because resolution detection can wait for an IRQ.

This issue was found by static analysis.

Fixes d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
Assisted-by LLM

---
Compile-tested with GCC, W=1 (arm64). No runtime testing.

 drivers/media/platform/aspeed/aspeed-video.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/aspeed/aspeed-video.c +1 -0
index a292275..4274b90 100644
@@ -2360,6 +2360,7 @@ static void aspeed_video_remove(struct platform_device *pdev)
 	struct v4l2_device *v4l2_dev = dev_get_drvdata(dev);
 	struct aspeed_video *video = to_aspeed_video(v4l2_dev);
 
+	disable_delayed_work_sync(&video->res_work);
 	aspeed_video_off(video);
 
 	aspeed_video_debugfs_remove(video);