From patchwork Thu Nov 18 14:44:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 72099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D9FA7B71A7 for ; Fri, 19 Nov 2010 01:42:56 +1100 (EST) Received: from localhost ([127.0.0.1]:36010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ5hO-00006l-Df for incoming@patchwork.ozlabs.org; Thu, 18 Nov 2010 09:42:54 -0500 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 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 74AD389783; Thu, 18 Nov 2010 15:42:10 +0100 (CET) Date: Thu, 18 Nov 2010 15:44:34 +0100 To: qemu-devel@nongnu.org User-Agent: Heirloom mailx 12.2 01/07/07 MIME-Version: 1.0 Message-Id: <20101118144434.3B68DF90AB@ochil.suse.de> From: hare@suse.de (Hannes Reinecke) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 Cc: stefanha@gmail.com, nab@linux-iscsi.org, kraxel@redhat.com Subject: [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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;