vhost: fix mem_sections memory corruption
authorAvi Kivity <avi@redhat.com>
Mon, 9 Jan 2012 11:59:50 +0000 (13:59 +0200)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jan 2012 11:59:50 +0000 (13:59 +0200)
A memset() used to delete an entry in an array did not take into account
the array element's size.

Signed-off-by: Avi Kivity <avi@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
hw/vhost.c

index 541c7163b26cfec7e0da0676e45578eca70ea92a..d924fb0e4df6368fc8d2354c81d47d5494d618cc 100644 (file)
@@ -456,7 +456,7 @@ static void vhost_region_del(MemoryListener *listener,
             == section->offset_within_address_space) {
             --dev->n_mem_sections;
             memmove(&dev->mem_sections[i], &dev->mem_sections[i+1],
-                    dev->n_mem_sections - i);
+                    (dev->n_mem_sections - i) * sizeof(*dev->mem_sections));
             break;
         }
     }