Patchwork virtio-serial-bus: fix ports_map allocation on init

login
register
mail settings
Submitter Amit Shah
Date May 19, 2010, 9:31 a.m.
Message ID <a42bfb91257238dc6adb3d0360e488f463490aca.1274261487.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/52967/
State New
Headers show

Comments

Amit Shah - May 19, 2010, 9:31 a.m.
From: Alon Levy <alevy@redhat.com>

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>
---
 hw/virtio-serial-bus.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Anthony Liguori - June 1, 2010, 6:27 p.m.
On 05/19/2010 04:31 AM, Amit Shah wrote:
> From: Alon Levy<alevy@redhat.com>
>
> 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>
>    

Applied.  Thanks.

Regards,

Anthony Liguori

> ---
>   hw/virtio-serial-bus.c |    3 ++-
>   1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 3ce95e8..7f9d28f 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -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)
>

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 3ce95e8..7f9d28f 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -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)