From: Takashi Iwai Subject: Re: [PATCH 3/6] topology: Use generic pointer to realloc buffer for private data Date: Sun, 08 May 2016 11:52:08 +0200 Message-ID: References: <1dd0f08c152af476e3a5af48ce7de97cd759616a.1461831763.git.mengdong.lin@linux.intel.com> <5721CE64.4060803@perex.cz> <5729507D.2010400@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id B101C260711 for ; Sun, 8 May 2016 11:52:09 +0200 (CEST) In-Reply-To: <5729507D.2010400@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mengdong Lin Cc: "alsa-devel@alsa-project.org" , "Shah, Hardik T" , "Singh, Guneshwor O" , "broonie@kernel.org" , "Girdwood, Liam R" , "Lin, Mengdong" List-Id: alsa-devel@alsa-project.org On Wed, 04 May 2016 03:29:33 +0200, Mengdong Lin wrote: > > > > On 04/28/2016 10:30 PM, Lin, Mengdong wrote: > >> -----Original Message----- > >> From: Takashi Iwai [mailto:tiwai@suse.de] > >> Sent: Thursday, April 28, 2016 9:55 PM > >> To: Jaroslav Kysela > >> Cc: mengdong.lin@linux.intel.com; alsa-devel@alsa-project.org; > >> broonie@kernel.org; Girdwood, Liam R; Lin, Mengdong; Shah, Hardik T; Singh, > >> Guneshwor O > >> Subject: Re: [PATCH 3/6] topology: Use generic pointer to realloc buffer for > >> private data > >> > >> On Thu, 28 Apr 2016 10:48:36 +0200, > >> Jaroslav Kysela wrote: > >>> > >>> Dne 28.4.2016 v 10:41 mengdong.lin@linux.intel.com napsal(a): > >>>> priv_data_size = ref->data->size; > >>>> + elem->obj = realloc(elem->obj, > >>>> + elem->size + priv_data_size); > >>>> + if (!elem->obj) > >>>> + return -ENOMEM; > >>> > >>> This causes a memory leak when realloc fails. You should free the > >>> original pointer when realloc() fails. > >> > >> Right, and the bug (the leak) has been already present before the patch... > >> > > > > Okay, we'll fix this. Thanks for pointing out this. > > > > I fixed this issue in v2 series. Would you please have a review? Now I'm back to online. Will start reviewing the series in tomorrow or so. thanks, Takashi