Skip to content

Commit 0fed0fc

Browse files
laeyraudgregkh
authored andcommitted
media: mtk-jpeg: cancel workqueue on release for supported platforms only
commit b1845a2 upstream. Since a recent fix the mtk_jpeg_release function cancels any pending or running work present in the driver workqueue using cancel_work_sync function. Currently, only the multicore based variants use this workqueue and they have the jpeg_worker platform data field initialized with a workqueue callback function. For the others, this field value remain NULL by default. The cancel_work_sync function is unconditionally called in mtk_jpeg_release function, even for the variants that do not use the workqueue. This call generates a WARN_ON print in __flush_work because the workqueue callback function presence check fails in __flush_work function (used by cancel_work_sync). So, to avoid these warnings, call cancel_work_sync only if a workqueue callback is defined in platform data. Fixes: 34c519f ("media: mtk-jpeg: fix use-after-free in release path due to uncancelled work") Cc: stable@vger.kernel.org Signed-off-by: Louis-Alexis Eyraud <louisalexis.eyraud@collabora.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 286f77d commit 0fed0fc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,8 @@ static int mtk_jpeg_release(struct file *file)
12141214
struct mtk_jpeg_dev *jpeg = video_drvdata(file);
12151215
struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(file->private_data);
12161216

1217-
cancel_work_sync(&ctx->jpeg_work);
1217+
if (jpeg->variant->jpeg_worker)
1218+
cancel_work_sync(&ctx->jpeg_work);
12181219
mutex_lock(&jpeg->lock);
12191220
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
12201221
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);

0 commit comments

Comments
 (0)