Patchwork s390: Fix buggy assignment

login
register
mail settings
Submitter Stefan Weil
Date Dec. 14, 2009, 9:39 a.m.
Message ID <1260783552-13025-1-git-send-email-weil@mail.berlios.de>
Download mbox | patch
Permalink /patch/41073/
State New
Headers show

Comments

Stefan Weil - Dec. 14, 2009, 9:39 a.m.
nd->model keeps dynamically allocated model names.
So casting of a constant string is wrong here.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/s390-virtio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Alexander Graf - Dec. 14, 2009, 10:06 a.m.
On 14.12.2009, at 10:39, Stefan Weil wrote:

> nd->model keeps dynamically allocated model names.
> So casting of a constant string is wrong here.
> 
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>

So we're wasting 7 bytes of strdup malloc'ed data we never free. Probably now worth thinking about though.

Acked-by: Alexander Graf <agraf@suse.de>

Patch

diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index b567886..b57fa9c 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -209,7 +209,7 @@  static void s390_init(ram_addr_t ram_size,
         DeviceState *dev;
 
         if (!nd->model) {
-            nd->model = (char*)"virtio";
+            nd->model = qemu_strdup("virtio");
         }
 
         if (strcmp(nd->model, "virtio")) {