All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: SamiUddinsami.md.ko@gmail.com
Cc: jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
	eperezma@redhat.com, virtualization@lists.linux.dev,
	linux-kernel@vger.kernel.org, Sami Uddin <sami.md.ko@gmail.com>
Subject: Re: [PATCH v2] virtio: reject shm region if length is zero
Date: Sun, 11 May 2025 11:36:13 -0400	[thread overview]
Message-ID: <20250511113555-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20250511114428.2061-1-sami.md.ko@gmail.com>

On Sun, May 11, 2025 at 09:14:28PM +0930, SamiUddinsami.md.ko@gmail.com wrote:
> From: Sami Uddin <sami.md.ko@gmail.com>
> 
> Prevent usage of shared memory regions where the length is zero,
> as such configurations are not valid and may lead to unexpected behavior.
> 
> Signed-off-by: Sami Uddin <sami.md.ko@gmail.com>
> ---
> v2:
> - Fixed coding style issue: added space after 'if' statement
> 
>  include/linux/virtio_config.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
> index 169c7d367fac..b641b16d42ef 100644
> --- a/include/linux/virtio_config.h
> +++ b/include/linux/virtio_config.h
> @@ -329,6 +329,8 @@ static inline
>  bool virtio_get_shm_region(struct virtio_device *vdev,
>  			   struct virtio_shm_region *region, u8 id)
>  {
> +	if (region->len == 0)
> +		return false;

if (!region->len)

is more idiomatic

>  	if (!vdev->config->get_shm_region)
>  		return false;
>  	return vdev->config->get_shm_region(vdev, region, id);
> -- 
> 2.34.1


      reply	other threads:[~2025-05-11 15:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-11 11:44 [PATCH v2] virtio: reject shm region if length is zero Sami
2025-05-11 15:36 ` Michael S. Tsirkin [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=20250511113555-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=SamiUddinsami.md.ko@gmail.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sami.md.ko@gmail.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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.