From d92c4bd840e5bf7ee4ce3b05ae8c57f25f206c98 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Thu, 12 Aug 2021 05:15:54 +0300 Subject: [PATCH] dm: fix potential NULL pointer access in virtio_console.c "port->cb" in 'virtio_console_notify_tx()' function maybe NULL when malicious inputs are injected from virtio frondend in guest. Tracked-On: #6388 Signed-off-by: Yonghua Huang --- devicemodel/hw/pci/virtio/virtio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devicemodel/hw/pci/virtio/virtio_console.c b/devicemodel/hw/pci/virtio/virtio_console.c index 3eda8badc..6b16b1f46 100644 --- a/devicemodel/hw/pci/virtio/virtio_console.c +++ b/devicemodel/hw/pci/virtio/virtio_console.c @@ -390,7 +390,7 @@ virtio_console_notify_tx(void *vdev, struct virtio_vq_info *vq) while (vq_has_descs(vq)) { vq_getchain(vq, &idx, iov, 1, flags); - if (port != NULL) + if ((port != NULL) && (port->cb != NULL)) port->cb(port, port->arg, iov, 1); /*