From: hare@suse.de (Hannes Reinecke)
To: qemu-devel@nongnu.org
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()
Date: Thu, 18 Nov 2010 15:44:34 +0100 [thread overview]
Message-ID: <20101118144434.3B68DF90AB@ochil.suse.de> (raw)
qemu_malloc doesn't check for zero argument, so we need to
check ourselves.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
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
next reply other threads:[~2010-11-18 14:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-18 14:44 Hannes Reinecke [this message]
2010-11-19 18:28 ` [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init() Christoph Hellwig
2010-11-22 9:01 ` Hannes Reinecke
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=20101118144434.3B68DF90AB@ochil.suse.de \
--to=hare@suse.de \
--cc=kraxel@redhat.com \
--cc=nab@linux-iscsi.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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).