Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794046097; b=LTdjCe6WsA7qn59qoB3cADx71v8OfuXT7k27mtgdhrXbPVSpbjsw5yRzjGkDFqFzk++e 39+UqpotZVjbAQCYjdewBpHFKeMqArbkgwniA6Woabh/E8qZCn23tG5fuq51I54dwAoNf dUedp/fRKDI1X1pzpTKJ1L2FxDdYbfn1DNC4N01QWNaqkOtvNXooZlIil3MowzHvvHHNW nBGgtd1vJKqvvG3/KAm25cK5iXWP5IFQYafmua+l3d/rlCSSFJA//ejfxYECeJ2UWayIG yBznI8h52AUwtGPObbZaiKD8ldT1N7Ea56puXG8eHFIo4bdlUJlYy42nnN7YvMQU52A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794046097; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=AVvqn606y6/iqNwKIfeW46fMxnwDsSEHtm8pjaMcfkU=; b=ZybJhoZEm8mBQPyRf3hjPx1ui8Xiuu0KC1blG2mg1O9bET+nB+1NGR9TgSvslvnJA+90 yJTo9LVs41nAdl3v129B8YqMVzYWk58LFylBUWOqMMLQMGa3YpQ1sHBNTxbHaYYSJM6ZD Sn5wrpao8/pvlJLmJgi3RhTJp4tLr3aVNL7DCyM2zjLoqlDJVOsyDjbrb4jlciX883cWk lypL15hnq5Y7fiqA30obc++djsyP3+dW9rVLSBVLnYvE/IPLLEIB6hi5y00lxlHklZUzb Ie/UYaOi3vY3+lWlv+MOkvfYazOV9k2A9leMNNcS5wePA2zNv9BmrR64BNQTO7msU7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TjNotDNz; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B465606A326 for ; Sat, 7 Nov 2026 10:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TjNotDNz Received: by smtp.kernel.org (Postfix) with ESMTPSA id A51D41F0089F; Sat, 7 Nov 2026 10:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794046097; bh=AVvqn606y6/iqNwKIfeW46fMxnwDsSEHtm8pjaMcfkU=; h=From:To:Cc:Subject:Date; b=TjNotDNzMJHRR3XKxwb1w+SZw7FiAhfqNRZrM7VQlKHFd9pRk89atF+85iMB4EVjF cvghJyPUIzESR+SWKmsNAEdfuc4sGQXtTZiAFC4kdViyZK4q09AwogRakSzgg4wSwh emMuFzWOnw+NhkpSeBAl+XiBsr/Gwq0JjleOa201nchtHdGYDy3mz7kuzNTBc0HtEg C6nev+7RCoGIn6OznWFbnnhc+DmNiwlBeORdoPTHyq0IG0JkvIwVxFlXLOVFwKkI28 Xqt3nva+uUDOA/Ndl4tFx3vKHUNzA2/juOlUuEWTDpVM1+0x6eOWsnpHo3dHa6rV7/ 2pnLMEWAO+IqA== From: Sasha Levin To: hnkz.64@gmail.com, nicolas.dufresne@collabora.com, hverkuil+cisco@kernel.org Cc: stable@vger.kernel.org Subject: FAILED: patch "[PATCH] media: mediatek: jpeg: Avoid context access after job finish" failed to apply to 6.18-stable tree Date: Sat, 7 Nov 2026 05:08:15 -0500 Message-ID: <20261107050815-failed-6.18-7c7f31405b76@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x 7c7f31405b76acd95a628c834ee8a2d6da439782 # git commit -s git send-email --to '' --in-reply-to '20261107050815-failed-6.18-7c7f31405b76@kernel.org' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Thanks, Sasha ------------------ original commit in Linus's tree ------------------ From 7c7f31405b76acd95a628c834ee8a2d6da439782 Mon Sep 17 00:00:00 2001 From: Kazuki Hanai Date: Wed, 2 Sep 2026 20:22:28 +0900 Subject: [PATCH] media: mediatek: jpeg: Avoid context access after job finish v4l2_m2m_job_finish() publishes job completion and wakes waiters before it returns. A concurrent file release can therefore finish v4l2_m2m_ctx_release() and free the context while the single-core IRQ handler continues with its tail. Both handlers only need the device for the matching runtime PM put. Use the IRQ-owned jpeg pointer instead of dereferencing ctx after completion has been published. This preserves the get/put pairing and removes the post-completion context access. Fixes: 45f13a57d813 ("media: platform: Add jpeg enc feature") Fixes: 5827e4b14ee7 ("media: platform: Improve power on and power off flow") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5 Signed-off-by: Kazuki Hanai Reviewed-by: Nicolas Dufresne Signed-off-by: Nicolas Dufresne Signed-off-by: Hans Verkuil --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 515c216058749..640ae30736f91 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1574,7 +1574,7 @@ static irqreturn_t mtk_jpeg_enc_done(struct mtk_jpeg_dev *jpeg) v4l2_m2m_buf_done(src_buf, buf_state); v4l2_m2m_buf_done(dst_buf, buf_state); v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); - pm_runtime_put(ctx->jpeg->dev); + pm_runtime_put(jpeg->dev); return IRQ_HANDLED; } @@ -1856,7 +1856,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) v4l2_m2m_buf_done(src_buf, buf_state); v4l2_m2m_buf_done(dst_buf, buf_state); v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); - pm_runtime_put(ctx->jpeg->dev); + pm_runtime_put(jpeg->dev); return IRQ_HANDLED; } -- 2.53.0