From: Yige Jiang <yigejiang86@gmail.com>
To: Philipp Zabel <p.zabel@pengutronix.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Yige Jiang <yigejiang86@gmail.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: [PATCH] media: coda: Release firmware if code buffer allocation fails
Date: Thu, 26 Nov 2026 13:21:54 +0800 [thread overview]
Message-ID: <rc-b1-20261126-vc-161-779570fc1703@gmail.com> (raw)
coda_fw_callback() owns the firmware passed to it by
request_firmware_nowait(). It normally releases the firmware after copying
it into the BIT processor's code buffer. If allocating that buffer fails,
the callback jumps to put_pm and skips release_firmware(), leaking the
firmware and its associated resources.
Release the firmware before jumping to put_pm, which drops the runtime PM
reference taken in coda_probe().
An AI coding assistant helped identify the leak during review of static
analysis results and helped draft the fix and commit message.
Fixes: 186b250a0725 ("[media] media: coda: Add driver for Coda video codec")
Cc: stable@vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64 coda-common.o with GCC 14.2 and W=1,
CONFIG_COMPILE_TEST=y, CONFIG_ARCH_MXC=y and CONFIG_VIDEO_CODA=m.
The baseline and patched object builds both produced 0 warnings.
No hardware or runtime test was performed.
The path needs the coherent DMA allocation of the code buffer to fail in the async firmware callback (OOM or fault injection).
drivers/media/platform/chips-media/coda/coda-common.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/chips-media/coda/coda-common.c b/drivers/media/platform/chips-media/coda/coda-common.c
index 3fe33c4..ca8f953 100644
--- a/drivers/media/platform/chips-media/coda/coda-common.c
+++ b/drivers/media/platform/chips-media/coda/coda-common.c
@@ -3004,8 +3004,10 @@ static void coda_fw_callback(const struct firmware *fw, void *context)
/* allocate auxiliary per-device code buffer for the BIT processor */
ret = coda_alloc_aux_buf(dev, &dev->codebuf, fw->size, "codebuf",
dev->debugfs_root);
- if (ret < 0)
+ if (ret < 0) {
+ release_firmware(fw);
goto put_pm;
+ }
coda_copy_firmware(dev, fw->data, fw->size);
release_firmware(fw);
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
next reply other threads:[~2026-11-26 5:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 5:21 Yige Jiang [this message]
2026-11-26 9:46 ` [PATCH] media: coda: Release firmware if code buffer allocation fails Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=rc-b1-20261126-vc-161-779570fc1703@gmail.com \
--to=yigejiang86@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox