From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C811471434; Tue, 21 Jul 2026 20:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665219; cv=none; b=pjfMev3gZMx6pJRDFkWdk+t38Oz1eSRAsu4SUNLwPdOwo40jyrnc8+K+Cog5gzYIoye1riUaOop/otj/+TCoBISUTmR7mJHBcR9xsf5vFk17nFiteAX4HshuaQkv4wBmtuXdUAItzFh8Oslck9xw7LLVuS4q4AitW4FN3NgJRS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784665219; c=relaxed/simple; bh=dk0oiHdDH/7FXmkGAIwm8evlRQ1lI1IS6w5aHsJtzjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QXpzX4Ff8cstMePSEVY7ZdFlWPRqRW/mLDbD7VYNZ9QSV7s64Oueo2Eii+6kGeUSqAbAyyF6r95lcYQRM20q9c3A6koci1c7jBcLoRU2SE/C29bNrsv/DVc9IDs4aPUjX71AEwUCD/FaND5CtfCGKeNdtSeBndt3LatyqOSl+KA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=D5PVprF/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="D5PVprF/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47C2A1F000E9; Tue, 21 Jul 2026 20:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784665217; bh=xxI0rg0f3ADTZZkGf/IkDTxso/srUidPOtNdl1H2AaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=D5PVprF/So2jzeaYNQd4pbktnpaBHeKX6Oy7svJ+GH6P6b1kUxKI3YOK0hrkraYwu aHzti7jtzN0t1OIKWrQ9AhWqMpjI61vgVmGrBPHeMAdaUASgXvAtdASFbnAbGy7E4M GAaZr4sk1ns/DG0/u6Pd17+d5mBfs6GYhBVgcOXI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Louis-Alexis Eyraud , Nicolas Dufresne , Hans Verkuil Subject: [PATCH 6.6 0219/1266] media: mtk-jpeg: cancel workqueue on release for supported platforms only Date: Tue, 21 Jul 2026 17:10:56 +0200 Message-ID: <20260721152446.719729553@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Louis-Alexis Eyraud commit b1845a227fda37b2fe5327df3ca0015d7e290235 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: 34c519feef3e ("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 Reviewed-by: Nicolas Dufresne Signed-off-by: Nicolas Dufresne Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1214,7 +1214,8 @@ static int mtk_jpeg_release(struct file struct mtk_jpeg_dev *jpeg = video_drvdata(file); struct mtk_jpeg_ctx *ctx = mtk_jpeg_fh_to_ctx(file->private_data); - cancel_work_sync(&ctx->jpeg_work); + if (jpeg->variant->jpeg_worker) + cancel_work_sync(&ctx->jpeg_work); mutex_lock(&jpeg->lock); v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); v4l2_ctrl_handler_free(&ctx->ctrl_hdl);