virtio-serial-bus: fix ports_map allocation on init
authorAlon Levy <alevy@redhat.com>
Wed, 19 May 2010 09:31:38 +0000 (15:01 +0530)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 1 Jun 2010 17:53:09 +0000 (12:53 -0500)
Fix for too small allocation to ports_map

Signed-off-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/virtio-serial-bus.c

index 3ce95e8..7f9d28f 100644 (file)
@@ -774,7 +774,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
     }
 
     vser->config.max_nr_ports = max_nr_ports;
-    vser->ports_map = qemu_mallocz((max_nr_ports + 31) / 32);
+    vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)
+        * sizeof(vser->ports_map[0]));
     /*
      * Reserve location 0 for a console port for backward compat
      * (old kernel, new qemu)