From 2f29ce885a999549324c4189796a0688e0c9b653 Mon Sep 17 00:00:00 2001
From: Pavel Fedin
Date: Wed, 13 Jan 2016 10:32:57 +0300
Subject: [PATCH] vhost: check memory map before address translation
Malfunctioning virtio clients may not send VHOST_USER_SET_MEM_TABLE for
some reason. This causes NULL dereference in qva_to_vva().
Signed-off-by: Pavel Fedin
Acked-by: Yuanhan Liu
---
lib/librte_vhost/virtio-net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index e189c74375..fe1a77e80b 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -632,7 +632,7 @@ vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
struct vhost_virtqueue *vq;
dev = get_device(ctx);
- if (dev == NULL)
+ if ((dev == NULL) || (dev->mem == NULL))
return -1;
/* addr->index refers to the queue index. The txq 1, rxq is 0. */
--
2.20.1