qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/smbus_eeprom.c : fix memory leak
@ 2011-12-02  3:23 Li Zhi Hui
  2011-12-02  3:47 ` Mark Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhi Hui @ 2011-12-02  3:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Li Zhi Hui, stefanha

Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com>
---
 hw/smbus_eeprom.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
index 5d080ab..d66fbbc 100644
--- a/hw/smbus_eeprom.c
+++ b/hw/smbus_eeprom.c
@@ -142,4 +142,5 @@ void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
         qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
         qdev_init_nofail(eeprom);
     }
+    g_free(eeprom_buf);
 }
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/smbus_eeprom.c : fix memory leak
  2011-12-02  3:23 [Qemu-devel] [PATCH] hw/smbus_eeprom.c : fix memory leak Li Zhi Hui
@ 2011-12-02  3:47 ` Mark Wu
  2011-12-02  5:41   ` Zhi Hui Li
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Wu @ 2011-12-02  3:47 UTC (permalink / raw)
  To: Li Zhi Hui; +Cc: qemu-trivial, qemu-devel, stefanha

On 12/02/2011 11:23 AM, Li Zhi Hui wrote:
> Signed-off-by: Li Zhi Hui<zhihuili@linux.vnet.ibm.com>
> ---
>   hw/smbus_eeprom.c |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
> index 5d080ab..d66fbbc 100644
> --- a/hw/smbus_eeprom.c
> +++ b/hw/smbus_eeprom.c
> @@ -142,4 +142,5 @@ void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
>           qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
>           qdev_init_nofail(eeprom);
>       }
> +    g_free(eeprom_buf);
>   }
The memory pointed by eeprom_buf is used as 'data' buf of 8 
SMBusEEPROMDevice after initialization.  And it calls qdev_init_nofail, 
which will exit on failure. it should be ok to leave it there. Anyway, 
you shouldn't free it in the initialization.

Mark.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/smbus_eeprom.c : fix memory leak
  2011-12-02  3:47 ` Mark Wu
@ 2011-12-02  5:41   ` Zhi Hui Li
  0 siblings, 0 replies; 3+ messages in thread
From: Zhi Hui Li @ 2011-12-02  5:41 UTC (permalink / raw)
  To: Mark Wu; +Cc: Stefan Hajnoczi, QEMU-devel

On 2011年12月02日 11:47, Mark Wu wrote:
> On 12/02/2011 11:23 AM, Li Zhi Hui wrote:
>> Signed-off-by: Li Zhi Hui<zhihuili@linux.vnet.ibm.com>
>> ---
>> hw/smbus_eeprom.c | 1 +
>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/hw/smbus_eeprom.c b/hw/smbus_eeprom.c
>> index 5d080ab..d66fbbc 100644
>> --- a/hw/smbus_eeprom.c
>> +++ b/hw/smbus_eeprom.c
>> @@ -142,4 +142,5 @@ void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom,
>> qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
>> qdev_init_nofail(eeprom);
>> }
>> + g_free(eeprom_buf);
>> }
> The memory pointed by eeprom_buf is used as 'data' buf of 8
> SMBusEEPROMDevice after initialization. And it calls qdev_init_nofail,
> which will exit on failure. it should be ok to leave it there. Anyway,
> you shouldn't free it in the initialization.
>
> Mark.
>
>
I'm afraid I was too fast when I sent a patch with memory leak, and 
don't look it carefully , It was a pointer to a pointer.

I agree with Mark Wu.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-02  5:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-02  3:23 [Qemu-devel] [PATCH] hw/smbus_eeprom.c : fix memory leak Li Zhi Hui
2011-12-02  3:47 ` Mark Wu
2011-12-02  5:41   ` Zhi Hui Li

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).