9pfs: fix crash when fsdev is missing
authorGreg Kurz <groug@kaod.org>
Tue, 3 Jan 2017 16:28:44 +0000 (17:28 +0100)
committerGreg Kurz <groug@kaod.org>
Tue, 3 Jan 2017 16:28:44 +0000 (17:28 +0100)
If the user passes -device virtio-9p without the corresponding -fsdev, QEMU
dereferences a NULL pointer and crashes.

This is a 2.8 regression introduced by commit 702dbcc274e2c.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
hw/9pfs/9p.c

index 97c2926aae50bd61c31b74074618c76d0b02025c..fa58877570f6d38b446805b62eb2f27f33a18cbf 100644 (file)
@@ -3525,7 +3525,7 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
     rc = 0;
 out:
     if (rc) {
-        if (s->ops->cleanup && s->ctx.private) {
+        if (s->ops && s->ops->cleanup && s->ctx.private) {
             s->ops->cleanup(&s->ctx);
         }
         g_free(s->tag);