From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRbEL-0001Lw-R3 for qemu-devel@nongnu.org; Wed, 10 Sep 2014 02:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRbEF-0007t0-JI for qemu-devel@nongnu.org; Wed, 10 Sep 2014 02:18:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRbEF-0007st-BM for qemu-devel@nongnu.org; Wed, 10 Sep 2014 02:18:07 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8A6I6Wj026043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Sep 2014 02:18:06 -0400 From: Fam Zheng Date: Wed, 10 Sep 2014 14:17:50 +0800 Message-Id: <1410329871-28885-3-git-send-email-famz@redhat.com> In-Reply-To: <1410329871-28885-1-git-send-email-famz@redhat.com> References: <1410329871-28885-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v3 2/3] vring: Better error handling if num is too large List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com To be more consistent inside this function. Signed-off-by: Fam Zheng --- hw/virtio/dataplane/vring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c index 67cb2b8..372706a 100644 --- a/hw/virtio/dataplane/vring.c +++ b/hw/virtio/dataplane/vring.c @@ -181,7 +181,8 @@ static int get_desc(Vring *vring, VirtQueueElement *elem, /* Stop for now if there are not enough iovecs available. */ if (*num >= VIRTQUEUE_MAX_SIZE) { - return -ENOBUFS; + error_report("Invalid SG num: %u", *num); + return -EFAULT; } /* TODO handle non-contiguous memory across region boundaries */ -- 1.9.3