* [PATCH v3 0/1] media: tegra-video: vi: fix invalid u32 return value in format lookup @ 2026-05-07 2:22 Hungyu Lin 2026-05-07 2:22 ` [PATCH v3 1/1] " Hungyu Lin 0 siblings, 1 reply; 4+ messages in thread From: Hungyu Lin @ 2026-05-07 2:22 UTC (permalink / raw) To: mchehab, gregkh, luca.ceresoli Cc: thierry.reding, jonathanh, skomatineni, digetx, hverkuil+cisco, dan.carpenter, linux-media, linux-tegra, linux-staging, linux-kernel, Hungyu Lin Changes in v3: - Add Fixes tag and Cc: stable@vger.kernel.org as suggested by Luca Ceresoli. - Add Reviewed-by: Luca Ceresoli. Changes in v2: - Follow Hans Verkuil's suggestion to use WARN_ON_ONCE() and return the first available format (index 0) as a safe fallback. Hungyu Lin (1): media: tegra-video: vi: fix invalid u32 return value in format lookup drivers/staging/media/tegra-video/vi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/1] media: tegra-video: vi: fix invalid u32 return value in format lookup 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 2026-05-07 4:06 ` Denny Lin 0 siblings, 1 reply; 4+ messages in thread From: Hungyu Lin @ 2026-05-07 2:22 UTC (permalink / raw) To: mchehab, gregkh, luca.ceresoli Cc: thierry.reding, jonathanh, skomatineni, digetx, hverkuil+cisco, dan.carpenter, linux-media, linux-tegra, linux-staging, linux-kernel, Hungyu Lin, stable 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 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/1] media: tegra-video: vi: fix invalid u32 return value in format lookup 2026-05-07 2:22 ` [PATCH v3 1/1] " Hungyu Lin @ 2026-05-07 4:06 ` Denny Lin 2026-05-07 21:04 ` Ricardo Ribalda Delgado 0 siblings, 1 reply; 4+ messages in thread From: Denny Lin @ 2026-05-07 4:06 UTC (permalink / raw) To: mchehab, gregkh, luca.ceresoli Cc: thierry.reding, jonathanh, skomatineni, digetx, hverkuil+cisco, dan.carpenter, linux-media, linux-tegra, linux-staging, linux-kernel, stable Hi, The media CI reports a missing Signed-off-by from Ricardo Ribalda, but this patch was submitted directly by me and has not been handled by any committer yet. I believe this is a false positive. Could you please confirm? Thanks, Hungyu On Wed, May 6, 2026 at 7:22 PM Hungyu Lin <dennylin0707@gmail.com> 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. > > 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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/1] media: tegra-video: vi: fix invalid u32 return value in format lookup 2026-05-07 4:06 ` Denny Lin @ 2026-05-07 21:04 ` Ricardo Ribalda Delgado 0 siblings, 0 replies; 4+ messages in thread From: Ricardo Ribalda Delgado @ 2026-05-07 21:04 UTC (permalink / raw) To: Denny Lin Cc: mchehab, gregkh, luca.ceresoli, thierry.reding, jonathanh, skomatineni, digetx, hverkuil+cisco, dan.carpenter, linux-media, linux-tegra, linux-staging, linux-kernel, stable Hi Denny On Thu, May 7, 2026 at 6:06 AM Denny Lin <dennylin0707@gmail.com> wrote: > > Hi, > > The media CI reports a missing Signed-off-by from Ricardo Ribalda, > but this patch was submitted directly by me and has not been handled > by any committer yet. > > I believe this is a false positive. It is indeed a false positive. Sorry about that Regards! > > Could you please confirm? > > Thanks, > Hungyu > > On Wed, May 6, 2026 at 7:22 PM Hungyu Lin <dennylin0707@gmail.com> 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. > > > > 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 > > > -- Ricardo Ribalda ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-07 21:05 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 ` [PATCH v3 1/1] " Hungyu Lin 2026-05-07 4:06 ` Denny Lin 2026-05-07 21:04 ` Ricardo Ribalda Delgado
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox