From: Elkin Cruz <elkin@google.com>
To: Keke Li <keke.li@amlogic.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, irogers@google.com,
Elkin Cruz <elkin@google.com>
Subject: [PATCH] media: amlogic: c3-mipi-csi2: clear csi->src_pad on error in enable_streams()
Date: Fri, 20 Nov 2026 19:24:32 +0000 [thread overview]
Message-ID: <20261120192432.2873409-1-elkin@google.com> (raw)
When media_pad_remote_pad_unique() fails in c3_mipi_csi_enable_streams(),
csi->src_pad is left holding an ERR_PTR() value. Subsequent calls such
as c3_mipi_csi_disable_streams() can then dereference the poisoned
struct member.
Reset csi->src_pad to NULL before returning -EPIPE.
Fixes: b63ef604a28d ("media: platform: Add C3 MIPI CSI-2 driver")
Signed-off-by: Elkin Cruz <elkin@google.com>
---
I am trying out a new Clang static analysis linter for ERR_PTR/NULL
handling, and it flagged this code as possibly buggy. The findings were triaged
and fixed with an AI coding assistant, then checked against linux-next (not
runtime-tested on hardware).
Thanks,
Elkin
drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
index b5e59e810e13..c261daef15b3 100644
--- a/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
+++ b/drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
@@ -426,6 +426,7 @@ static int c3_mipi_csi_enable_streams(struct v4l2_subdev *sd,
csi->src_pad = media_pad_remote_pad_unique(sink_pad);
if (IS_ERR(csi->src_pad)) {
dev_dbg(csi->dev, "Failed to get source pad for MIPI CSI-2\n");
+ csi->src_pad = NULL;
return -EPIPE;
}
--
2.56.1.750.gf70dc682cf-goog
reply other threads:[~2026-11-20 19:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261120192432.2873409-1-elkin@google.com \
--to=elkin@google.com \
--cc=irogers@google.com \
--cc=keke.li@amlogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mchehab@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
all inboxes | Powered by JetHome®