From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWLsx-00063x-Bl for qemu-devel@nongnu.org; Fri, 02 Dec 2011 00:42:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWLsw-0008CY-3b for qemu-devel@nongnu.org; Fri, 02 Dec 2011 00:42:11 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:40498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWLsv-0008C6-CM for qemu-devel@nongnu.org; Fri, 02 Dec 2011 00:42:10 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Dec 2011 11:12:00 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB25fv2Y3108964 for ; Fri, 2 Dec 2011 11:11:58 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB25fvma031267 for ; Fri, 2 Dec 2011 16:41:57 +1100 Message-ID: <4ED86523.2000801@linux.vnet.ibm.com> Date: Fri, 02 Dec 2011 13:41:55 +0800 From: Zhi Hui Li MIME-Version: 1.0 References: <1322796212-324-1-git-send-email-zhihuili@linux.vnet.ibm.com> <4ED84A55.5060106@linux.vnet.ibm.com> In-Reply-To: <4ED84A55.5060106@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] hw/smbus_eeprom.c : fix memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 >> --- >> 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.