From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Alexandru Hossu <hossu.alexandru@gmail.com>,
Thierry Reding <thierry.reding@gmail.com>,
Sowjanya Komatineni <skomatineni@nvidia.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-media@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] staging: media: tegra-video: fix wrong return type in tegra_get_format_fourcc_by_idx()
Date: Wed, 6 May 2026 09:05:03 +0200 [thread overview]
Message-ID: <4db267a6-4d00-4777-a7d9-c18b303624c1@kernel.org> (raw)
In-Reply-To: <20260411211006.150782-1-hossu.alexandru@gmail.com>
On 11/04/2026 23:10, Alexandru Hossu wrote:
> The function is declared to return u32, but returns -EINVAL on the error
> path. Due to implicit conversion, -EINVAL (-22) becomes 0xFFFFFFEA as u32,
> which is an invalid V4L2 pixel format value.
>
> The caller tegra_channel_enum_format() assigns this garbage value directly
> to f->pixelformat and returns 0 (success) to userspace via VIDIOC_ENUM_FMT,
> giving applications a silently wrong format descriptor instead of an error.
>
> Fix this by changing the return type to int and propagating the error
> correctly in the caller.
>
> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>
It's a duplicate of https://patchwork.linuxtv.org/project/linux-media/patch/20260412000245.26696-1-dennylin0707@gmail.com/
I prefer that version (after my suggested change) over this one.
Regards,
Hans
> ---
> drivers/staging/media/tegra-video/vi.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
> index 9c0b38585d63..afc7327ef318 100644
> --- a/drivers/staging/media/tegra-video/vi.c
> +++ b/drivers/staging/media/tegra-video/vi.c
> @@ -77,13 +77,13 @@ static int tegra_get_format_idx_by_code(struct tegra_vi *vi,
> return -1;
> }
>
> -static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi,
> +static int tegra_get_format_fourcc_by_idx(struct tegra_vi *vi,
> unsigned int index)
> {
> if (index >= vi->soc->nformats)
> return -EINVAL;
>
> - return vi->soc->video_formats[index].fourcc;
> + return (int)vi->soc->video_formats[index].fourcc;
> }
>
> static const struct tegra_video_format *
> @@ -395,6 +395,7 @@ static int tegra_channel_enum_format(struct file *file, void *fh,
> struct tegra_vi_channel *chan = video_drvdata(file);
> unsigned int index = 0, i;
> unsigned long *fmts_bitmap = chan->tpg_fmts_bitmap;
> + int ret;
>
> if (!IS_ENABLED(CONFIG_VIDEO_TEGRA_TPG))
> fmts_bitmap = chan->fmts_bitmap;
> @@ -405,7 +406,11 @@ static int tegra_channel_enum_format(struct file *file, void *fh,
> for (i = 0; i < f->index + 1; i++, index++)
> index = find_next_bit(fmts_bitmap, MAX_FORMAT_NUM, index);
>
> - f->pixelformat = tegra_get_format_fourcc_by_idx(chan->vi, index - 1);
> + ret = tegra_get_format_fourcc_by_idx(chan->vi, index - 1);
> + if (ret < 0)
> + return ret;
> +
> + f->pixelformat = ret;
>
> return 0;
> }
prev parent reply other threads:[~2026-05-06 7:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-11 21:10 [PATCH 1/2] staging: media: tegra-video: fix wrong return type in tegra_get_format_fourcc_by_idx() Alexandru Hossu
2026-04-11 21:10 ` [PATCH 2/2] staging: media: tegra-video: add missing error checks in vi_tpg_fmts_bitmap_init() Alexandru Hossu
2026-04-12 4:52 ` Greg Kroah-Hartman
2026-04-13 7:21 ` Dan Carpenter
2026-04-13 7:27 ` [PATCH 1/2] staging: media: tegra-video: fix wrong return type in tegra_get_format_fourcc_by_idx() Dan Carpenter
2026-05-06 7:05 ` Hans Verkuil [this message]
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=4db267a6-4d00-4777-a7d9-c18b303624c1@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hossu.alexandru@gmail.com \
--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=thierry.reding@gmail.com \
/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