vhost_dev->protocol_features field can be legitimately set to NULL
as apparently it's vhost-user only field. At least I was able to get
NULL deref with a vhost-net VM.
Without that check querying vhost-net device:
info virtio-status /machine/peripheral-anon/device[0]/virtio-backend
will lead to SIGSEGV.
Fixes: 8a8287981d1169f534894d983ecfd3b70b71918b ("hmp: add virtio commands")
Cc: [email protected]
Signed-off-by: Nikolay Kuratov <[email protected]>
---
hw/virtio/virtio-hmp-cmds.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/virtio/virtio-hmp-cmds.c b/hw/virtio/virtio-hmp-cmds.c
index 1daae482d3..b9980197ef 100644
--- a/hw/virtio/virtio-hmp-cmds.c
+++ b/hw/virtio/virtio-hmp-cmds.c
@@ -15,6 +15,9 @@
static void hmp_virtio_dump_protocols(Monitor *mon,
VhostDeviceProtocols *pcol)
{
+ if (pcol == NULL) {
+ return;
+ }
strList *pcol_list = pcol->protocols;
while (pcol_list) {
monitor_printf(mon, "\t%s", pcol_list->value);
--
2.34.1