All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	linux-media@vger.kernel.org
Cc: kernel@collabora.com, laurent.pinchart@ideasonboard.com,
	dafna3@gmail.com, sakari.ailus@linux.intel.com,
	mchehab@kernel.org
Subject: Re: [PATCH v2 2/2] media: videobuf2: add WARN_ON if bytesused is bigger than buffer length
Date: Wed, 24 Nov 2021 16:47:04 +0100	[thread overview]
Message-ID: <bad9cd33-7cff-6966-9e4d-da1f0be5df9b@xs4all.nl> (raw)
In-Reply-To: <20211111152640.1537-3-dafna.hirschfeld@collabora.com>

On 11/11/2021 16:26, Dafna Hirschfeld wrote:
> In function vb2_set_plane_payload, report if the
> given bytesused is bigger than the buffer size,
> and clamp it to the buffer size.
> 
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> ---
>  include/media/videobuf2-core.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
> index 2467284e5f26..e06c190265f0 100644
> --- a/include/media/videobuf2-core.h
> +++ b/include/media/videobuf2-core.h
> @@ -1155,8 +1155,14 @@ static inline void *vb2_get_drv_priv(struct vb2_queue *q)
>  static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
>  				 unsigned int plane_no, unsigned long size)
>  {
> -	if (plane_no < vb->num_planes)
> +	/*
> +	 * size must never be larger than the buffer length, so
> +	 * warn and clamp to the buffer length if that's the case.
> +	 */
> +	if (plane_no < vb->num_planes) {
> +		WARN_ON_ONCE(size > vb->planes[plane_no].length);

This doesn't clamp size to the buffer length, so this needs to be added.

Also, the subject talks about WARN_ON instead of WARN_ON_ONCE.

Regards,

	Hans

>  		vb->planes[plane_no].bytesused = size;
> +	}
>  }
>  
>  /**
> 


      parent reply	other threads:[~2021-11-24 15:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 15:26 [PATCH v2 0/2] media: videobuf2: make sure bytesused is smaller than the buffer size Dafna Hirschfeld
2021-11-11 15:26 ` [PATCH v2 1/2] media: replace setting of bytesused with vb2_set_plane_payload Dafna Hirschfeld
2021-11-16  2:24   ` kernel test robot
2021-11-16  2:24     ` kernel test robot
2021-11-11 15:26 ` [PATCH v2 2/2] media: videobuf2: add WARN_ON if bytesused is bigger than buffer length Dafna Hirschfeld
2021-11-12  0:10   ` Laurent Pinchart
2021-11-24 15:47   ` 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=bad9cd33-7cff-6966-9e4d-da1f0be5df9b@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=dafna3@gmail.com \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.