hw/smbus_eeprom.c : fix memory leak
PATCH 1/1 hw/smbus_eeprom.c : fix memory leak
--- hw/smbus_eeprom.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/smbus_eeprom.c +1 -0
@@ -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); }
Signature · 1 line
1.7.4.1
Quoted 10 lines · Li Zhi Hui
Signed-off-by Li Zhi Hui<[email protected]>--- hw/smbus_eeprom.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)hw/smbus_eeprom.c +0
-0
hw/smbus_eeprom.c void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom, · line 146
Quoted 5 lines
hw/smbus_eeprom.c +1
-0@@ -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.
Quoted 21 lines · Mark Wu
Quoted 10 lines · Li Zhi Hui
Signed-off-by Li Zhi Hui<[email protected]>---
hw/smbus_eeprom.c| 1 +1 files changed, 1 insertions(+), 0 deletions(-)hw/smbus_eeprom.c +0
-0hw/smbus_eeprom.c void smbus_eeprom_init(i2c_bus *smbus, int nb_eeprom, · line 146
Quoted 5 lines
hw/smbus_eeprom.c +1
-0@@ -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_bufis used as 'data' buf of 8 SMBusEEPROMDevice after initialization. And it callsqdev_init_nofail, which will exit on failure. it should be ok to leave it there. Anyway, you shouldn't free it in the initialization.
Quoted 3 lines
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.