From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: Re: [PATCH v2 02/10] libxl: turn two malloc's to libxl__malloc Date: Mon, 13 Jul 2015 18:15:37 +0100 Message-ID: <21923.62009.540660.399207@mariner.uk.xensource.com> References: <1436804541-12965-1-git-send-email-wei.liu2@citrix.com> <1436804541-12965-3-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.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZEhKS-0005K7-6B for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 17:15:44 +0000 In-Reply-To: <1436804541-12965-3-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 Cc: Xen-devel , Ian Campbell List-Id: xen-devel@lists.xenproject.org Wei Liu writes ("[PATCH v2 02/10] libxl: turn two malloc's to libxl__malloc"): > One is to combine malloc + libxl__alloc_failed. The other is to avoid > dereferencing NULL pointer in case of malloc failure. The former fix is simply corredt. > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > index ad434f0..0cc73be 100644 > --- a/tools/libxl/libxl_dm.c > +++ b/tools/libxl/libxl_dm.c > @@ -1010,7 +1010,7 @@ static int libxl__write_stub_dmargs(libxl__gc *gc, > i++; > } > dmargs_size++; > - dmargs = (char *) malloc(dmargs_size); > + dmargs = (char *) libxl__malloc(NOGC, dmargs_size); This latter should IMO be fixed by using the gc, as well. Ian.