qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init()
@ 2010-11-18 14:44 Hannes Reinecke
  2010-11-19 18:28 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Hannes Reinecke @ 2010-11-18 14:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, nab, kraxel


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-22  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-18 14:44 [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init() Hannes Reinecke
2010-11-19 18:28 ` Christoph Hellwig
2010-11-22  9:01   ` Hannes Reinecke

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).