vhost: fix error handling when mem table gets updated
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Fri, 12 Oct 2018 12:40:33 +0000 (14:40 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 18 Oct 2018 08:24:39 +0000 (10:24 +0200)
When the memory table gets updated, the rings addresses need
to be translated again. If it fails, we need to exit cleanly
by unmapping memory regions.

Fixes: d5022533c20a ("vhost: retranslate vring addr when memory table changes")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Ilya Maximets <i.maximets@samsung.com>
lib/librte_vhost/vhost_user.c

index 1ef02c9..83d3e63 100644 (file)
@@ -953,8 +953,10 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg)
                        vring_invalidate(dev, vq);
 
                        dev = translate_ring_addresses(dev, i);
-                       if (!dev)
-                               return VH_RESULT_ERR;
+                       if (!dev) {
+                               dev = *pdev;
+                               goto err_mmap;
+                       }
 
                        *pdev = dev;
                }