Patchwork [v3,01/15] target-i386: Fix x86_cpuid_set_model_id()

login
register
mail settings
Submitter Andreas Färber
Date April 24, 2012, 2:22 p.m.
Message ID <1335277351-30379-1-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/154684/
State New
Headers show

Comments

Andreas Färber - April 24, 2012, 2:22 p.m.
Don't assume zeroed cpuid_model[] fields.

This didn't break anything yet but QOM properties should be able to set
the value to something else without setting an intermediate zero string.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 Since I managed to screw this change up on first try (using size 12),
 let's better be safe than sorry and properly post the v3 for review. :-)
 
 v2 -> v3:
 * Use memset() instead of for loop (suggested by Igor Mammedov).

 target-i386/cpu.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 3df53ca..e1517e6 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -627,6 +627,7 @@  static void x86_cpuid_set_model_id(CPUX86State *env, const char *model_id)
         model_id = "";
     }
     len = strlen(model_id);
+    memset(env->cpuid_model, 0, 48);
     for (i = 0; i < 48; i++) {
         if (i >= len) {
             c = '\0';