Skip to content

Commit 83c8511

Browse files
Icenowyopsiff
authored andcommitted
media: mtk-jpeg: only init/cancel work for multi-core variants
Single-core variants of this hardware do not use the work at all, and the worker function is set to NULL, which leads to warnings when cancelling the work in release callback. Skip the work init/cancel code when the JPEG hardware isn't multi-core. Cc: stable@vger.kernel.org Fixes: 34c519feef3e ("media: mtk-jpeg: fix use-after-free in release path due to uncancelled work") Fixes: d40e952 ("media: mtk-jpeg: reconstructs the initialization mode of worker") Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn> Link: https://lore.kernel.org/all/20260601073218.1281840-1-zhengxingda@iscas.ac.cn/ Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
1 parent abf5cf1 commit 83c8511

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,8 @@ static int mtk_jpeg_open(struct file *file)
11671167
goto free;
11681168
}
11691169

1170-
INIT_WORK(&ctx->jpeg_work, jpeg->variant->jpeg_worker);
1170+
if (jpeg->variant->multi_core)
1171+
INIT_WORK(&ctx->jpeg_work, jpeg->variant->jpeg_worker);
11711172
INIT_LIST_HEAD(&ctx->dst_done_queue);
11721173
spin_lock_init(&ctx->done_queue_lock);
11731174
v4l2_fh_init(&ctx->fh, vfd);
@@ -1209,7 +1210,8 @@ static int mtk_jpeg_release(struct file *file)
12091210
struct mtk_jpeg_dev *jpeg = video_drvdata(file);
12101211
struct mtk_jpeg_ctx *ctx = mtk_jpeg_file_to_ctx(file);
12111212

1212-
cancel_work_sync(&ctx->jpeg_work);
1213+
if (jpeg->variant->multi_core)
1214+
cancel_work_sync(&ctx->jpeg_work);
12131215
mutex_lock(&jpeg->lock);
12141216
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
12151217
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);

0 commit comments

Comments
 (0)