qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Max Reitz <mreitz@redhat.com>,
	stefanha@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2] virtio-scsi: Fix num_queue input validation
Date: Fri, 31 Oct 2014 11:26:58 +0100	[thread overview]
Message-ID: <545363F2.3050507@redhat.com> (raw)
In-Reply-To: <1414724671-31052-1-git-send-email-famz@redhat.com>

On 31/10/2014 04:04, Fam Zheng wrote:
> We need to count the ctrlq and eventq, and also cleanup before
> returning. Besides, the format string should be unsigned.
> 
> The number could never be less than zero.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  hw/scsi/virtio-scsi.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 7d40ecc..fdcacfd 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -804,10 +804,12 @@ void virtio_scsi_common_realize(DeviceState *dev, Error **errp,
>      virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI,
>                  sizeof(VirtIOSCSIConfig));
>  
> -    if (s->conf.num_queues <= 0 || s->conf.num_queues > VIRTIO_PCI_QUEUE_MAX) {
> -        error_setg(errp, "Invalid number of queues (= %" PRId32 "), "
> +    if (s->conf.num_queues == 0 ||
> +            s->conf.num_queues > VIRTIO_PCI_QUEUE_MAX - 2) {
> +        error_setg(errp, "Invalid number of queues (= %" PRIu32 "), "
>                           "must be a positive integer less than %d.",
> -                   s->conf.num_queues, VIRTIO_PCI_QUEUE_MAX);
> +                   s->conf.num_queues, VIRTIO_PCI_QUEUE_MAX - 2);
> +        virtio_cleanup(vdev);
>          return;
>      }
>      s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
> 

Thanks, applied.

Paolo

      reply	other threads:[~2014-10-31 15:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31  3:04 [Qemu-devel] [PATCH v2] virtio-scsi: Fix num_queue input validation Fam Zheng
2014-10-31 10:26 ` Paolo Bonzini [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=545363F2.3050507@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=famz@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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;
as well as URLs for NNTP newsgroup(s).