mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: Ricardo Ribalda <ribalda@chromium.org>,
	Mauro Carvalho Chehab	 <mchehab@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil@kernel.org>,
	Nas Chung	 <nas.chung@chipsnmedia.com>,
	Jackson Lee <jackson.lee@chipsnmedia.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Keke Li <keke.li@amlogic.com>, Yong Zhi <yong.zhi@intel.com>,
	 Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-staging@lists.linux.dev,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Subject: Re: [PATCH v4 4/6] media: chips-media: wave5: Add range checks for dec_output_info
Date: Thu, 07 May 2026 19:27:24 -0400	[thread overview]
Message-ID: <2e891600319c2fd4219ed32d884c2b5bd975c3d0.camel@ndufresne.ca> (raw)
In-Reply-To: <20260507-smatch-7-1-v4-4-cc195f142167@chromium.org>

[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]

Le jeudi 07 mai 2026 à 20:58 +0000, Ricardo Ribalda a écrit :
> If the driver's dec_output_info contains invalid data the driver can
> write in invalid memory. Add a range check for that.
> 
> This fixes this smatch error:
> drivers/media/platform/chips-media/wave5/wave5-vpuapi.c:588
> wave5_vpu_dec_get_output_info() error: buffer overflow 'inst->frame_buf' 64 <=
> 127
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>

It theoretical, but considering its a warn_on, I'm fine with it.

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  drivers/media/platform/chips-media/wave5/wave5-vpuapi.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> index d26ffc942219..f77abd5e122a 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> @@ -584,8 +584,15 @@ int wave5_vpu_dec_get_output_info(struct vpu_instance
> *inst, struct dec_output_i
>  		p_dec_info->num_of_decoding_fbs : p_dec_info-
> >num_of_display_fbs;
>  
>  	if (info->index_frame_display >= 0 &&
> -	    info->index_frame_display < (int)max_dec_index)
> -		info->disp_frame = inst->frame_buf[val + info-
> >index_frame_display];
> +	    info->index_frame_display < (int)max_dec_index) {
> +		u32 idx = val + info->index_frame_display;
> +
> +		if (WARN_ON(idx >= MAX_REG_FRAME)) {
> +			ret = -EINVAL;
> +			goto err_out;
> +		}
> +		info->disp_frame = inst->frame_buf[idx];
> +	}
>  
>  	info->rd_ptr = p_dec_info->stream_rd_ptr;
>  	info->wr_ptr = p_dec_info->stream_wr_ptr;

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-05-07 23:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07 20:58 [PATCH v4 0/6] media: Fix new smatch warnings Ricardo Ribalda
2026-05-07 20:58 ` [PATCH v4 1/6] media: v4l2-dev: Add range check for vdev->minor Ricardo Ribalda
2026-05-07 20:58 ` [PATCH v4 2/6] media: i2c: mt9p031: Rewrite assignment to make smatch happy Ricardo Ribalda
2026-05-07 20:58 ` [PATCH v4 3/6] media: i2c: adv7604: Add range checks for chip info Ricardo Ribalda
2026-05-07 20:58 ` [PATCH v4 4/6] media: chips-media: wave5: Add range checks for dec_output_info Ricardo Ribalda
2026-05-07 23:27   ` Nicolas Dufresne [this message]
2026-05-07 20:58 ` [PATCH v4 5/6] media: staging: ipu3-imgu: Add range check for imgu_css_cfg_acc_stripe Ricardo Ribalda
2026-05-22 16:49   ` Sakari Ailus
2026-05-07 20:58 ` [PATCH v4 6/6] media: amlogic-c3: Add validations for ae and awb config Ricardo Ribalda
2026-05-08  6:27   ` Keke Li

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=2e891600319c2fd4219ed32d884c2b5bd975c3d0.camel@ndufresne.ca \
    --to=nicolas@ndufresne.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil@kernel.org \
    --cc=jackson.lee@chipsnmedia.com \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=keke.li@amlogic.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab+samsung@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nas.chung@chipsnmedia.com \
    --cc=ribalda@chromium.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yong.zhi@intel.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

all inboxes | Powered by JetHome®