Skip to contentSkip to conversation

dma-helpers: Initialize DMAAIOCB in_cancel flag

PATCH Applied Peter Maydell 3 participants 5 messages Mar 28, 2014 – Apr 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dma-helpers: Initialize DMAAIOCB in_cancel flag

Initialize the dbs->in_cancel flag in dma_bdrv_io(), since qemu_aio_get() does not return zero-initialized memory. Spotted by the clang sanitizer (which complained when the value loaded in dma_complete() was not valid for a bool type); this might have resulted in leaking the AIO block.

---

 dma-helpers.c | 1 +
 1 file changed, 1 insertion(+)
dma-helpers.c +1 -0
index c9620a5..5f421e9 100644
@@ -213,6 +213,7 @@ BlockDriverAIOCB *dma_bdrv_io(
     dbs->sg_cur_index = 0;
     dbs->sg_cur_byte = 0;
     dbs->dir = dir;
+    dbs->in_cancel = false;
     dbs->io_func = io_func;
     dbs->bh = NULL;
     qemu_iovec_init(&dbs->iov, sg->nsg);
Signature · 1 line
1.9.0
#1 lore raw
Quoted 4 lines · Peter Maydell

Initialize the dbs->in_cancel flag in dma_bdrv_io(), since qemu_aio_get() does not return zero-initialized memory. Spotted by the clang sanitizer (which complained when the value loaded in dma_complete() was not valid for a bool type); this might have resulted in leaking the AIO block.

Please ignore the 1/2 in the header -- this is a single standalone patch, I just fluffed the git-format-patch command.

thanks
-- PMM

#2 lore raw
In reply to Peter Maydell
Quoted 24 lines · Peter Maydell

Initialize the dbs->in_cancel flag in dma_bdrv_io(), since qemu_aio_get() does not return zero-initialized memory. Spotted by the clang sanitizer (which complained when the value loaded in dma_complete() was not valid for a bool type); this might have resulted in leaking the AIO block.

---

 dma-helpers.c | 1 +
 1 file changed, 1 insertion(+)
dma-helpers.c +1 -1
index c9620a5..5f421e9 100644
@@ -213,6 +213,7 @@ BlockDriverAIOCB *dma_bdrv_io(
     dbs->sg_cur_index = 0;
     dbs->sg_cur_byte = 0;
     dbs->dir = dir;
+    dbs->in_cancel = false;
     dbs->io_func = io_func;
     dbs->bh = NULL;
     qemu_iovec_init(&dbs->iov, sg->nsg);
--
Quoted 1 line

1.9.0

Ping, or do we think this isn't worthwhile for 2.0?

(I guess I should have stuck a for-2.0 in the subject.)

thanks
-- PMM

Reviewed-by on v1 1/2
#3 lore raw
In reply to Peter Maydell
Quoted 16 lines · Peter Maydell

Initialize the dbs->in_cancel flag in dma_bdrv_io(), since qemu_aio_get() does not return zero-initialized memory. Spotted by the clang sanitizer (which complained when the value loaded in dma_complete() was not valid for a bool type); this might have resulted in leaking the AIO block.

---

 dma-helpers.c | 1 +
 1 file changed, 1 insertion(+)
dma-helpers.c +0 -0
index c9620a5..5f421e9 100644

dma-helpers.c BlockDriverAIOCB *dma_bdrv_io( · line 219

Quoted 7 lines
dma-helpers.c +1 -0
@@ -213,6 +213,7 @@ BlockDriverAIOCB *dma_bdrv_io(
     dbs->sg_cur_index = 0;
     dbs->sg_cur_byte = 0;
     dbs->dir = dir;
+    dbs->in_cancel = false;
     dbs->io_func = io_func;
     dbs->bh = NULL;
     qemu_iovec_init(&dbs->iov, sg->nsg);

Worth merging for 2.0.

Applied
#4 lore raw
In reply to Peter Maydell

Am 28.03.2014 um 15:22 hat Peter Maydell geschrieben:

Quoted 6 lines

Initialize the dbs->in_cancel flag in dma_bdrv_io(), since qemu_aio_get() does not return zero-initialized memory. Spotted by the clang sanitizer (which complained when the value loaded in dma_complete() was not valid for a bool type); this might have resulted in leaking the AIO block.

Thanks, applied to the block branch.

Kevin