4d7edd7
From: Greg Kurz <groug@kaod.org>
4d7edd7
Date: Tue, 3 Jan 2017 17:28:44 +0100
4d7edd7
Subject: [PATCH] 9pfs: fix crash when fsdev is missing
4d7edd7
4d7edd7
If the user passes -device virtio-9p without the corresponding -fsdev, QEMU
4d7edd7
dereferences a NULL pointer and crashes.
4d7edd7
4d7edd7
This is a 2.8 regression introduced by commit 702dbcc274e2c.
4d7edd7
4d7edd7
Signed-off-by: Greg Kurz <groug@kaod.org>
4d7edd7
Reviewed-by: Li Qiang <liq3ea@gmail.com>
4d7edd7
(cherry picked from commit f2b58c43758efc61e2a49b899f5e58848489d0dc)
4d7edd7
---
4d7edd7
 hw/9pfs/9p.c | 2 +-
4d7edd7
 1 file changed, 1 insertion(+), 1 deletion(-)
4d7edd7
4d7edd7
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
4d7edd7
index 84be1c8..be2095a 100644
4d7edd7
--- a/hw/9pfs/9p.c
4d7edd7
+++ b/hw/9pfs/9p.c
4d7edd7
@@ -3481,7 +3481,7 @@ int v9fs_device_realize_common(V9fsState *s, Error **errp)
4d7edd7
     rc = 0;
4d7edd7
 out:
4d7edd7
     if (rc) {
4d7edd7
-        if (s->ops->cleanup && s->ctx.private) {
4d7edd7
+        if (s->ops && s->ops->cleanup && s->ctx.private) {
4d7edd7
             s->ops->cleanup(&s->ctx);
4d7edd7
         }
4d7edd7
         g_free(s->tag);