* [Qemu-devel] [PATCH 0/3] x86/cpuid: A few trivial fixes
@ 2011-11-08 14:36 Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 1/3] x86/cpuid: Convert remaining strdup() to g_strdup() Markus Armbruster
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 14:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
Markus Armbruster (3):
x86/cpuid: Convert remaining strdup() to g_strdup()
x86/cpuid: Plug memory leak in cpudef_setfield()
x86/cpuid: Fix crash on -cpu ""
target-i386/cpuid.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
--
1.7.6.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/3] x86/cpuid: Convert remaining strdup() to g_strdup()
2011-11-08 14:36 [Qemu-devel] [PATCH 0/3] x86/cpuid: A few trivial fixes Markus Armbruster
@ 2011-11-08 14:36 ` Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 2/3] x86/cpuid: Plug memory leak in cpudef_setfield() Markus Armbruster
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 14:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
Fixes missing error checking.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
target-i386/cpuid.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 1e8bcff..7c8f1be 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -600,7 +600,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
unsigned int i;
x86_def_t *def;
- char *s = strdup(cpu_model);
+ char *s = g_strdup(cpu_model);
char *featurestr, *name = strtok(s, ",");
/* Features to be added*/
uint32_t plus_features = 0, plus_ext_features = 0;
@@ -746,11 +746,11 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
if (check_features_against_host(x86_cpu_def) && enforce_cpuid)
goto error;
}
- free(s);
+ g_free(s);
return 0;
error:
- free(s);
+ g_free(s);
return -1;
}
@@ -969,7 +969,7 @@ static int cpudef_setfield(const char *name, const char *str, void *opaque)
int err = 0;
if (!strcmp(name, "name")) {
- def->name = strdup(str);
+ def->name = g_strdup(str);
} else if (!strcmp(name, "model_id")) {
strncpy(def->model_id, str, sizeof (def->model_id));
} else if (!strcmp(name, "level")) {
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/3] x86/cpuid: Plug memory leak in cpudef_setfield()
2011-11-08 14:36 [Qemu-devel] [PATCH 0/3] x86/cpuid: A few trivial fixes Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 1/3] x86/cpuid: Convert remaining strdup() to g_strdup() Markus Armbruster
@ 2011-11-08 14:36 ` Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 3/3] x86/cpuid: Fix crash on -cpu "" Markus Armbruster
2011-11-09 10:13 ` [Qemu-devel] [Qemu-trivial] [PATCH 0/3] x86/cpuid: A few trivial fixes Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 14:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
To reproduce the leak, put two name options into the same [cpudef]
section of target-x86_64.conf.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
target-i386/cpuid.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 7c8f1be..0fce752 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -969,6 +969,7 @@ static int cpudef_setfield(const char *name, const char *str, void *opaque)
int err = 0;
if (!strcmp(name, "name")) {
+ g_free((void *)def->name);
def->name = g_strdup(str);
} else if (!strcmp(name, "model_id")) {
strncpy(def->model_id, str, sizeof (def->model_id));
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 3/3] x86/cpuid: Fix crash on -cpu ""
2011-11-08 14:36 [Qemu-devel] [PATCH 0/3] x86/cpuid: A few trivial fixes Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 1/3] x86/cpuid: Convert remaining strdup() to g_strdup() Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 2/3] x86/cpuid: Plug memory leak in cpudef_setfield() Markus Armbruster
@ 2011-11-08 14:36 ` Markus Armbruster
2011-11-09 10:13 ` [Qemu-devel] [Qemu-trivial] [PATCH 0/3] x86/cpuid: A few trivial fixes Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2011-11-08 14:36 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
target-i386/cpuid.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 0fce752..9fc9769 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -613,9 +613,9 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
uint32_t numvalue;
for (def = x86_defs; def; def = def->next)
- if (!strcmp(name, def->name))
+ if (name && !strcmp(name, def->name))
break;
- if (kvm_enabled() && strcmp(name, "host") == 0) {
+ if (kvm_enabled() && name && strcmp(name, "host") == 0) {
cpu_x86_fill_host(x86_cpu_def);
} else if (!def) {
goto error;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH 0/3] x86/cpuid: A few trivial fixes
2011-11-08 14:36 [Qemu-devel] [PATCH 0/3] x86/cpuid: A few trivial fixes Markus Armbruster
` (2 preceding siblings ...)
2011-11-08 14:36 ` [Qemu-devel] [PATCH 3/3] x86/cpuid: Fix crash on -cpu "" Markus Armbruster
@ 2011-11-09 10:13 ` Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2011-11-09 10:13 UTC (permalink / raw)
To: Markus Armbruster; +Cc: qemu-trivial, qemu-devel
On Tue, Nov 08, 2011 at 03:36:47PM +0100, Markus Armbruster wrote:
> Markus Armbruster (3):
> x86/cpuid: Convert remaining strdup() to g_strdup()
> x86/cpuid: Plug memory leak in cpudef_setfield()
> x86/cpuid: Fix crash on -cpu ""
>
> target-i386/cpuid.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-09 10:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 14:36 [Qemu-devel] [PATCH 0/3] x86/cpuid: A few trivial fixes Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 1/3] x86/cpuid: Convert remaining strdup() to g_strdup() Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 2/3] x86/cpuid: Plug memory leak in cpudef_setfield() Markus Armbruster
2011-11-08 14:36 ` [Qemu-devel] [PATCH 3/3] x86/cpuid: Fix crash on -cpu "" Markus Armbruster
2011-11-09 10:13 ` [Qemu-devel] [Qemu-trivial] [PATCH 0/3] x86/cpuid: A few trivial fixes Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).