]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
sheepdog: fix NULL dereference in sd_create
authorLiu Yuan <namei.unix@gmail.com>
Tue, 17 Jun 2014 05:45:35 +0000 (13:45 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 23 Jun 2014 08:36:13 +0000 (16:36 +0800)
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>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/sheepdog.c

index 2dcc5959f494862faf0eea67a7b50ec74ef99789..8d9350c26d2256c36048934fc7c6f49ebf06fb76 100644 (file)
@@ -1756,6 +1756,7 @@ static int sd_create(const char *filename, QemuOpts *opts,
         bdrv_unref(bs);
     }
 
+    s->aio_context = qemu_get_aio_context();
     ret = do_sd_create(s, &vid, 0, errp);
     if (ret) {
         goto out;