Skip to contentSkip to conversation

Fix leaks on object_property_add_str() setters

PATCH RESEND Applied Eduardo Habkost 4 participants 16 messages Aug 6, 2014 – Sep 4, 2014

lore
Share & tools
lore
#0 lore raw

cover Fix leaks on object_property_add_str() setters

Resending two patches from the previous series which were not applied yet.

Eduardo Habkost (2):
rng-egd: Free old chr_name value before setting new one hw/machine: Free old values of string properties

 backends/rng-egd.c | 1 +
 hw/core/machine.c  | 8 ++++++++
 2 files changed, 9 insertions(+)
Signature · 1 line
1.9.3
#1 lore raw

PATCH RESEND 1/2 rng-egd: Free old chr_name value before setting new one

---
 backends/rng-egd.c | 1 +
 1 file changed, 1 insertion(+)
backends/rng-egd.c +1 -0
index 25bb3b4..2962795 100644
@@ -169,6 +169,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
     if (b->opened) {
         error_set(errp, QERR_PERMISSION_DENIED);
     } else {
+        g_free(s->chr_name);
         s->chr_name = g_strdup(value);
     }
 }
Signature · 1 line
1.9.3
#5 lore raw

PATCH RESEND 2/2 hw/machine: Free old values of string properties

In reply to Eduardo Habkost
---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/core/machine.c +8 -0
index 7a66c57..d145aca 100644
@@ -24,6 +24,7 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->accel);
     ms->accel = g_strdup(value);
 }
 
@@ -79,6 +80,7 @@ static void machine_set_kernel(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->kernel_filename);
     ms->kernel_filename = g_strdup(value);
 }
 
@@ -93,6 +95,7 @@ static void machine_set_initrd(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->initrd_filename);
     ms->initrd_filename = g_strdup(value);
 }
 
@@ -107,6 +110,7 @@ static void machine_set_append(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->kernel_cmdline);
     ms->kernel_cmdline = g_strdup(value);
 }
 
@@ -121,6 +125,7 @@ static void machine_set_dtb(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dtb);
     ms->dtb = g_strdup(value);
 }
 
@@ -135,6 +140,7 @@ static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dumpdtb);
     ms->dumpdtb = g_strdup(value);
 }
 
@@ -176,6 +182,7 @@ static void machine_set_dt_compatible(Object *obj, const char *value, Error **er
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dt_compatible);
     ms->dt_compatible = g_strdup(value);
 }
 
@@ -232,6 +239,7 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->firmware);
     ms->firmware = g_strdup(value);
 }
 
Signature · 1 line
1.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH RESEND 1/2] rng-egd: Free old chr_name value before setting new one

In reply to Eduardo Habkost
Quoted 11 lines · Eduardo Habkost
---
 backends/rng-egd.c | 1 +
 1 file changed, 1 insertion(+)
backends/rng-egd.c +0 -0
index 25bb3b4..2962795 100644

backends/rng-egd.c static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp) · line 175

Quoted 7 lines
backends/rng-egd.c +1 -0
@@ -169,6 +169,7 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)
     if (b->opened) {
         error_set(errp, QERR_PERMISSION_DENIED);
     } else {
+        g_free(s->chr_name);
         s->chr_name = g_strdup(value);
     }
 }

Eduardo, a similar patch had been applied.

commit 5e490b6a504912225dff0e520e1c6af68295d238

Author: Amos Kong <[email protected]>
Date:   Thu Nov 21 16:42:50 2013 +0800

rng-egd: remove redundant free

We didn't set default chr_name, the free is redundant.

Message-id: [email protected]

Quoted 2 lines
Signature · 1 line
1.9.3
Signature · 1 line
			Amos.
Reviewed-by on v1 2/2
#6 lore raw

Re: [Qemu-devel] [PATCH RESEND 2/2] hw/machine: Free old values of string properties

In reply to Eduardo Habkost
Quoted 3 lines · Eduardo Habkost
Quoted 75 lines
---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/core/machine.c +8 -0
index 7a66c57..d145aca 100644
@@ -24,6 +24,7 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->accel);
     ms->accel = g_strdup(value);
 }
 
@@ -79,6 +80,7 @@ static void machine_set_kernel(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->kernel_filename);
     ms->kernel_filename = g_strdup(value);
 }
 
@@ -93,6 +95,7 @@ static void machine_set_initrd(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->initrd_filename);
     ms->initrd_filename = g_strdup(value);
 }
 
@@ -107,6 +110,7 @@ static void machine_set_append(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->kernel_cmdline);
     ms->kernel_cmdline = g_strdup(value);
 }
 
@@ -121,6 +125,7 @@ static void machine_set_dtb(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dtb);
     ms->dtb = g_strdup(value);
 }
 
@@ -135,6 +140,7 @@ static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dumpdtb);
     ms->dumpdtb = g_strdup(value);
 }
 
@@ -176,6 +182,7 @@ static void machine_set_dt_compatible(Object *obj, const char *value, Error **er
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dt_compatible);
     ms->dt_compatible = g_strdup(value);
 }
 
@@ -232,6 +239,7 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->firmware);
     ms->firmware = g_strdup(value);
 }
 
Signature · 1 line
1.9.3
Signature · 1 line
			Amos.
#3 lore raw

Re: [Qemu-devel] [PATCH RESEND 1/2] rng-egd: Free old chr_name value before setting new one

In reply to Amos Kong

Il 07/08/2014 04:24, Amos Kong ha scritto:

Quoted 6 lines

Eduardo, a similar patch had been applied.

commit 5e490b6a504912225dff0e520e1c6af68295d238

Author: Amos Kong <[email protected]>
Date:   Thu Nov 21 16:42:50 2013 +0800
Quoted 8 lines

rng-egd: remove redundant free

We didn't set default chr_name, the free is redundant.

Message-id: [email protected]

What if you set chr_name twice?

Paolo

#8 lore raw
In reply to Eduardo Habkost

Ping? Who can apply these?

Quoted 15 lines · Eduardo Habkost

Resending two patches from the previous series which were not applied yet.

Eduardo Habkost (2):
rng-egd: Free old chr_name value before setting new one hw/machine: Free old values of string properties

 backends/rng-egd.c | 1 +
 hw/core/machine.c  | 8 ++++++++
 2 files changed, 9 insertions(+)
Signature · 1 line
1.9.3
Signature · 1 line
Eduardo
#9 lore raw

Are these appropriate for 2.1.1?
Add Cc stable?

Quoted 21 lines · Eduardo Habkost

Ping? Who can apply these?

Quoted 15 lines · Eduardo Habkost

Resending two patches from the previous series which were not applied yet.

Eduardo Habkost (2):
rng-egd: Free old chr_name value before setting new one hw/machine: Free old values of string properties

 backends/rng-egd.c | 1 +
 hw/core/machine.c  | 8 ++++++++
 2 files changed, 9 insertions(+)
Signature · 1 line
1.9.3
Signature · 1 line
Eduardo
#10 lore raw

Il 24/08/2014 13:16, Michael S. Tsirkin ha scritto:

Quoted 3 lines

Are these appropriate for 2.1.1?
Add Cc stable?

I think so.

Paolo

#4 lore raw

Re: [Qemu-devel] [PATCH RESEND 1/2] rng-egd: Free old chr_name value before setting new one

In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini

Il 07/08/2014 04:24, Amos Kong ha scritto:

Quoted 8 lines

Eduardo, a similar patch had been applied.

commit 5e490b6a504912225dff0e520e1c6af68295d238

Author: Amos Kong <[email protected]>
Date:   Thu Nov 21 16:42:50 2013 +0800

rng-egd: remove redundant free

Quoted 8 lines
Quoted 6 lines

We didn't set default chr_name, the free is redundant.

Message-id: [email protected]

What if you set chr_name twice?

In this case, g_free() is necessary.

So I'm fine with Eduardo's patch: [PATCH RESEND 1/2] rng-egd: Free old chr_name value

Quoted 1 line

Paolo

Signature · 1 line
			Amos.
#11 lore raw
In reply to Paolo Bonzini
Quoted 6 lines · Paolo Bonzini

Il 24/08/2014 13:16, Michael S. Tsirkin ha scritto:

Quoted 3 lines

Are these appropriate for 2.1.1?
Add Cc stable?

I think so.

I agree it can go to -stable, but just getting it applied to master is being difficult enough. :(

Repeating my question from 2 weeks ago: who can apply these?

Signature · 1 line
Eduardo
#7 lore raw

Re: [Qemu-devel] [PATCH RESEND 2/2] hw/machine: Free old values of string properties

In reply to Eduardo Habkost
Quoted 3 lines · Eduardo Habkost

Applied, thanks!

Quoted 75 lines
---
 hw/core/machine.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/core/machine.c +8 -0
index 7a66c57..d145aca 100644
@@ -24,6 +24,7 @@ static void machine_set_accel(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->accel);
     ms->accel = g_strdup(value);
 }
 
@@ -79,6 +80,7 @@ static void machine_set_kernel(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->kernel_filename);
     ms->kernel_filename = g_strdup(value);
 }
 
@@ -93,6 +95,7 @@ static void machine_set_initrd(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->initrd_filename);
     ms->initrd_filename = g_strdup(value);
 }
 
@@ -107,6 +110,7 @@ static void machine_set_append(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->kernel_cmdline);
     ms->kernel_cmdline = g_strdup(value);
 }
 
@@ -121,6 +125,7 @@ static void machine_set_dtb(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dtb);
     ms->dtb = g_strdup(value);
 }
 
@@ -135,6 +140,7 @@ static void machine_set_dumpdtb(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dumpdtb);
     ms->dumpdtb = g_strdup(value);
 }
 
@@ -176,6 +182,7 @@ static void machine_set_dt_compatible(Object *obj, const char *value, Error **er
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->dt_compatible);
     ms->dt_compatible = g_strdup(value);
 }
 
@@ -232,6 +239,7 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
 
+    g_free(ms->firmware);
     ms->firmware = g_strdup(value);
 }
 
Signature · 1 line
1.9.3
#12 lore raw
In reply to Eduardo Habkost
Quoted 6 lines · Eduardo Habkost
Quoted 5 lines · Paolo Bonzini

Il 24/08/2014 13:16, Michael S. Tsirkin ha scritto:

Quoted 3 lines

Are these appropriate for 2.1.1?
Add Cc stable?

Quoted 6 lines
Quoted 1 line

I think so.

I agree it can go to -stable, but just getting it applied to master is being difficult enough. :(

Repeating my question from 2 weeks ago: who can apply these?

I applied 2/2, 1/2 is no longer needed IIUC?

Quoted 2 lines
Signature · 1 line
Eduardo
#13 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Eduardo Habkost
Quoted 5 lines · Paolo Bonzini

Il 24/08/2014 13:16, Michael S. Tsirkin ha scritto:

Quoted 3 lines

Are these appropriate for 2.1.1?
Add Cc stable?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think so.

I agree it can go to -stable, but just getting it applied to master is being difficult enough. :(

Repeating my question from 2 weeks ago: who can apply these?

I applied 2/2, 1/2 is no longer needed IIUC?

Added Cc: [email protected] as well.

Quoted 2 lines
Quoted 2 lines
Signature · 1 line
Eduardo
#14 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Eduardo Habkost
Quoted 5 lines · Paolo Bonzini

Il 24/08/2014 13:16, Michael S. Tsirkin ha scritto:

Quoted 3 lines

Are these appropriate for 2.1.1?
Add Cc stable?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think so.

I agree it can go to -stable, but just getting it applied to master is being difficult enough. :(

Repeating my question from 2 weeks ago: who can apply these?

I applied 2/2, 1/2 is no longer needed IIUC?

It is still needed. The "similar patch" Amos mentioned (commit 5e490b6a504912225dff0e520e1c6af68295d238) is actually the one that introduces the bug I am fixing (I just didn't use git-revert because I wasn't aware of that commit).

Signature · 1 line
Eduardo
#15 lore raw
Quoted 13 lines · Eduardo Habkost
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Eduardo Habkost
Quoted 6 lines · Paolo Bonzini

Il 24/08/2014 13:16, Michael S. Tsirkin ha scritto:

Quoted 3 lines

Are these appropriate for 2.1.1?
Add Cc stable?

I think so.

I agree it can go to -stable, but just getting it applied to master is being difficult enough. :(

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Repeating my question from 2 weeks ago: who can apply these?

I applied 2/2, 1/2 is no longer needed IIUC?

It is still needed. The "similar patch" Amos mentioned (commit 5e490b6a504912225dff0e520e1c6af68295d238) is actually the one that introduces the bug I am fixing (I just didn't use git-revert because I wasn't aware of that commit).

OK will apply as revert.

Quoted 2 lines
Signature · 1 line
Eduardo