diff mbox

sheepdog: fix NULL dereference in sd_create

Message ID 1402983935-14920-1-git-send-email-namei.unix@gmail.com
State New
Headers show

Commit Message

Liu Yuan June 17, 2014, 5:45 a.m. UTC
Following command

qemu-img create -f qcow2 sheepdog:test 20g

will cause core dump because aio_context is NULL in sd_create. We should
initialize it by qemu_get_aio_context() to avoid NULL dereference.

Cc: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
---
 block/sheepdog.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stefan Hajnoczi June 19, 2014, 9:43 a.m. UTC | #1
On Tue, Jun 17, 2014 at 01:45:35PM +0800, Liu Yuan wrote:
> Following command
> 
> qemu-img create -f qcow2 sheepdog:test 20g
> 
> will cause core dump because aio_context is NULL in sd_create. We should
> initialize it by qemu_get_aio_context() to avoid NULL dereference.
> 
> Cc: qemu-devel@nongnu.org
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Liu Yuan <namei.unix@gmail.com>
> ---
>  block/sheepdog.c | 1 +
>  1 file changed, 1 insertion(+)

Sorry about this, it's my fault.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 1fa1939..47a8b5a 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1761,6 +1761,7 @@  static int sd_create(const char *filename, QEMUOptionParameter *options,
         bdrv_unref(bs);
     }
 
+    s->aio_context = qemu_get_aio_context();
     ret = do_sd_create(s, &vid, 0, errp);
     if (ret) {
         goto out;