From: Hungyu Lin <dennylin0707@gmail.com>
To: mchehab@kernel.org, gregkh@linuxfoundation.org,
luca.ceresoli@bootlin.com
Cc: thierry.reding@kernel.org, jonathanh@nvidia.com,
skomatineni@nvidia.com, digetx@gmail.com,
hverkuil+cisco@kernel.org, dan.carpenter@linaro.org,
linux-media@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Hungyu Lin <dennylin0707@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v3 1/1] media: tegra-video: vi: fix invalid u32 return value in format lookup
Date: Thu, 7 May 2026 02:22:13 +0000 [thread overview]
Message-ID: <20260507022213.29290-2-dennylin0707@gmail.com> (raw)
In-Reply-To: <20260507022213.29290-1-dennylin0707@gmail.com>
tegra_get_format_fourcc_by_idx() returns a u32 but uses -EINVAL to
signal an out-of-bounds index. This results in a large unsigned
value being returned, which may be interpreted as a valid fourcc.
Returning 0 is not a valid fourcc either. This condition should
never happen, so use WARN_ON_ONCE() to catch unexpected out-of-bounds
access and return a valid fallback format instead.
Suggested-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Fixes: 3d8a97eabef0 ("media: tegra-video: Add Tegra210 Video input driver")
Cc: stable@vger.kernel.org
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
drivers/staging/media/tegra-video/vi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index f14cdc7b5211..456134a9e8cf 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -80,8 +80,8 @@ static int tegra_get_format_idx_by_code(struct tegra_vi *vi,
static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi,
unsigned int index)
{
- if (index >= vi->soc->nformats)
- return -EINVAL;
+ if (WARN_ON_ONCE(index >= vi->soc->nformats))
+ return vi->soc->video_formats[0].fourcc;
return vi->soc->video_formats[index].fourcc;
}
--
2.34.1
next prev parent reply other threads:[~2026-05-07 2:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 2:22 [PATCH v3 0/1] media: tegra-video: vi: fix invalid u32 return value in format lookup Hungyu Lin
2026-05-07 2:22 ` Hungyu Lin [this message]
2026-05-07 4:06 ` [PATCH v3 1/1] " Denny Lin
2026-05-07 21:04 ` Ricardo Ribalda Delgado
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=20260507022213.29290-2-dennylin0707@gmail.com \
--to=dennylin0707@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=digetx@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil+cisco@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mchehab@kernel.org \
--cc=skomatineni@nvidia.com \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@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