Received: from [140.186.70.92] (port=33014 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ5gm-00005i-Ik for qemu-devel@nongnu.org; Thu, 18 Nov 2010 09:42:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ5gh-000101-BV for qemu-devel@nongnu.org; Thu, 18 Nov 2010 09:42:16 -0500 Received: from cantor2.suse.de ([195.135.220.15]:47006 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ5gh-0000zv-6c for qemu-devel@nongnu.org; Thu, 18 Nov 2010 09:42:11 -0500 Date: Thu, 18 Nov 2010 15:44:34 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20101118144434.3B68DF90AB@ochil.suse.de> From: hare@suse.de (Hannes Reinecke) Subject: [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, nab@linux-iscsi.org, kraxel@redhat.com qemu_malloc doesn't check for zero argument, so we need to check ourselves. Signed-off-by: Hannes Reinecke --- dma-helpers.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/dma-helpers.c b/dma-helpers.c index 712ed89..877b2c3 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -12,7 +12,10 @@ void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint) { - qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); + if (alloc_hint > 0) + qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); + else + qsg->sg = NULL; qsg->nsg = 0; qsg->nalloc = alloc_hint; qsg->size = 0; -- 1.7.1