ivshmem: check shm isn't already initialized
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 23 Jun 2015 10:55:41 +0000 (12:55 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Sat, 24 Oct 2015 16:02:49 +0000 (18:02 +0200)
The server should not change the shm, and this isn't handled by qemu and
we should should verify this in qemu.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
hw/misc/ivshmem.c

index d3d02048cd14fa1595aa98769ccd2346cdf38b0d..9023f95711466a4bb00ebffac32fb4cf3d71f196 100644 (file)
@@ -533,6 +533,12 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
     if (incoming_posn == -1) {
         void * map_ptr;
 
+        if (s->shm_fd >= 0) {
+            error_report("shm already initialized");
+            close(incoming_fd);
+            return;
+        }
+
         if (check_shm_size(s, incoming_fd, &err) == -1) {
             error_report_err(err);
             close(incoming_fd);