From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH for-4.6 v2 6/8] libxlu: free buffer in failure path for PCI related functions Date: Tue, 28 Jul 2015 11:35:21 +0100 Message-ID: <1438079721.11600.119.camel@citrix.com> References: <1438019109-31997-1-git-send-email-wei.liu2@citrix.com> <1438019109-31997-7-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZK2ER-0001BZ-R0 for xen-devel@lists.xenproject.org; Tue, 28 Jul 2015 10:35:35 +0000 In-Reply-To: <1438019109-31997-7-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu , Xen-devel Cc: Ian Jackson List-Id: xen-devel@lists.xenproject.org On Mon, 2015-07-27 at 18:45 +0100, Wei Liu wrote: > Signed-off-by: Wei Liu > --- > tools/libxl/libxlu_pci.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/libxl/libxlu_pci.c b/tools/libxl/libxlu_pci.c > index 026413b..16ddaf7 100644 > --- a/tools/libxl/libxlu_pci.c > +++ b/tools/libxl/libxlu_pci.c > @@ -178,6 +178,7 @@ int xlu_pci_parse_bdf(XLU_Config *cfg, > libxl_device_pci *pcidev, const char *str > return 0; > > parse_error: > + free(buf2); There is a path (half a dozen lines above) which can do free(buf2) followed by goto parse_error. That free ought to set buf2=NULL, or the free needs to move after that check on the success path. > return ERROR_INVAL; > } > > @@ -254,6 +255,7 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve > *rdm, const char *str) > return 0; > > parse_error: > + free(buf2); Same here. > return ERROR_INVAL; > } >