Skip to contentSkip to conversation

9pfs: fix crash when fsdev is missing

PATCH In review Greg Kurz 2 participants 2 messages Dec 19, 2016 – Dec 20, 2016

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 9pfs: fix crash when fsdev is missing

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.

---
 hw/9pfs/9p.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p.c +1 -1
index faebd91f5fab..68725b7a1c97 100644
@@ -3521,7 +3521,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);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · On 2016-12-19 22:28 GMT+08:00 Greg Kurz <[email protected]> wrote:

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.

Quoted 20 lines
---
 hw/9pfs/9p.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p.c +1 -1
index faebd91f5fab..68725b7a1c97 100644
@@ -3521,7 +3521,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);