Allow zero alloc_hint in qemu_sglist_init()
PATCH 1/16 Allow zero alloc_hint in qemu_sglist_init()
qemu_malloc doesn't check for zero argument, so we need to check ourselves.
Signed-off-by Hannes Reinecke <[email protected]>
--- dma-helpers.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
dma-helpers.c +4 -1
@@ -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 ;
Signature · 1 line
1.7.1
Quoted 3 lines · Hannes Reinecke
qemu_mallocdoesn't check for zero argument, so we need to check ourselves.
I'm not sure if it's a that good idea to remove the implicit ->sg != NULL assumption. Any reason you can't simply call qemu_sglist_init later?
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Hannes Reinecke
qemu_mallocdoesn't check for zero argument, so we need to check ourselves.I'm not sure if it's a that good idea to remove the implicit ->sg != NULL assumption. Any reason you can't simply call
qemu_sglist_initlater?
We can actually drop this. It's a leftover from the old interface.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Markus Rex, HRB 16746 (AG Nürnberg)