diff mbox

[6/6] smbus: fix memory leak

Message ID 1456998223-12356-7-git-send-email-arei.gonglei@huawei.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gonglei (Arei) March 3, 2016, 9:43 a.m. UTC
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/i2c/smbus_eeprom.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paolo Bonzini March 3, 2016, 11:19 a.m. UTC | #1
On 03/03/2016 10:43, Gonglei wrote:
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  hw/i2c/smbus_eeprom.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
> index 5b7bd89..83c6b27 100644
> --- a/hw/i2c/smbus_eeprom.c
> +++ b/hw/i2c/smbus_eeprom.c
> @@ -156,4 +156,6 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
>          qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
>          qdev_init_nofail(eeprom);
>      }
> +
> +    g_free(eeprom_buf);
>  }
> 

This is wrong, eeprom_buf is passed to the device through qdev_prop_set_ptr.

Paolo
Gonglei (Arei) March 3, 2016, 12:05 p.m. UTC | #2
> Subject: Re: [PATCH 6/6] smbus: fix memory leak
> 
> 
> 
> On 03/03/2016 10:43, Gonglei wrote:
> > Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> > ---
> >  hw/i2c/smbus_eeprom.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
> > index 5b7bd89..83c6b27 100644
> > --- a/hw/i2c/smbus_eeprom.c
> > +++ b/hw/i2c/smbus_eeprom.c
> > @@ -156,4 +156,6 @@ void smbus_eeprom_init(I2CBus *smbus, int
> nb_eeprom,
> >          qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
> >          qdev_init_nofail(eeprom);
> >      }
> > +
> > +    g_free(eeprom_buf);
> >  }
> >
> 
> This is wrong, eeprom_buf is passed to the device through qdev_prop_set_ptr.
> 
Oops, right, NACK. Thanks!


Regards,
-Gonglei
diff mbox

Patch

diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c
index 5b7bd89..83c6b27 100644
--- a/hw/i2c/smbus_eeprom.c
+++ b/hw/i2c/smbus_eeprom.c
@@ -156,4 +156,6 @@  void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
         qdev_prop_set_ptr(eeprom, "data", eeprom_buf + (i * 256));
         qdev_init_nofail(eeprom);
     }
+
+    g_free(eeprom_buf);
 }