* [PATCH] media: tegra-video: vi: fix invalid u32 return value in format lookup
@ 2026-04-12 0:02 Hungyu Lin
2026-04-13 7:34 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Hungyu Lin @ 2026-04-12 0:02 UTC (permalink / raw)
To: thierry.reding, jonathanh, skomatineni, luca.ceresoli
Cc: mchehab, gregkh, linux-media, linux-tegra, linux-staging,
linux-kernel, Hungyu Lin
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.
Return 0 instead to indicate an invalid format.
Callers assign the return value directly to pixelformat, so returning
an error code encoded in u32 is unsafe.
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
drivers/staging/media/tegra-video/vi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 9c0b38585d63..966792a6ec19 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -81,7 +81,7 @@ static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi,
unsigned int index)
{
if (index >= vi->soc->nformats)
- return -EINVAL;
+ return 0;
return vi->soc->video_formats[index].fourcc;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: tegra-video: vi: fix invalid u32 return value in format lookup
2026-04-12 0:02 [PATCH] media: tegra-video: vi: fix invalid u32 return value in format lookup Hungyu Lin
@ 2026-04-13 7:34 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-04-13 7:34 UTC (permalink / raw)
To: Hungyu Lin
Cc: thierry.reding, jonathanh, skomatineni, luca.ceresoli, mchehab,
gregkh, linux-media, linux-tegra, linux-staging, linux-kernel
On Sun, Apr 12, 2026 at 12:02:45AM +0000, Hungyu Lin wrote:
> 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.
>
> Return 0 instead to indicate an invalid format.
>
> Callers assign the return value directly to pixelformat, so returning
> an error code encoded in u32 is unsafe.
>
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
> drivers/staging/media/tegra-video/vi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
> index 9c0b38585d63..966792a6ec19 100644
> --- a/drivers/staging/media/tegra-video/vi.c
> +++ b/drivers/staging/media/tegra-video/vi.c
> @@ -81,7 +81,7 @@ static u32 tegra_get_format_fourcc_by_idx(struct tegra_vi *vi,
> unsigned int index)
> {
> if (index >= vi->soc->nformats)
> - return -EINVAL;
> + return 0;
Someone else just sent a patch for this which added error checking to
the caller. I liked that approach better. (I haven't checked to see
if your approach works).
But either way this needs further review to see if the bug is actually
real and if so what is the Fixes tag?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-13 7:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 0:02 [PATCH] media: tegra-video: vi: fix invalid u32 return value in format lookup Hungyu Lin
2026-04-13 7:34 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox