From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH 2/3] tools/libxl/libxl_cpuid.c: Fix leak of resstr on error path Date: Tue, 17 Mar 2015 15:44:16 +0000 Message-ID: <20150317154416.GC20522@zion.uk.xensource.com> References: <1426500377-40643-1-git-send-email-pramod.devendra@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 1YXtig-0006pX-Js for xen-devel@lists.xenproject.org; Tue, 17 Mar 2015 15:47:50 +0000 Content-Disposition: inline In-Reply-To: <1426500377-40643-1-git-send-email-pramod.devendra@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: PRAMOD DEVENDRA Cc: xen-devel@lists.xenproject.org, Wei Liu , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Mon, Mar 16, 2015 at 10:06:17AM +0000, PRAMOD DEVENDRA wrote: > From: Pramod Devendra > > Signed-off-by: Pramod Devendra > CC: Ian Jackson > CC: Stefano Stabellini > CC: Ian Campbell > CC: Wei Liu Acked-by: Wei Liu > --- > tools/libxl/libxl_cpuid.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c > index b0bdc9d..c66e912 100644 > --- a/tools/libxl/libxl_cpuid.c > +++ b/tools/libxl/libxl_cpuid.c > @@ -223,9 +223,6 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) > } > entry = cpuid_find_match(cpuid, flag->leaf, flag->subleaf); > resstr = entry->policy[flag->reg - 1]; > - if (resstr == NULL) { > - resstr = strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); > - } Minor nit. I would prefer "resstr = " be grouped with the code you moved. No need to resend though. Wei. > num = strtoull(val, &endptr, 0); > flags[flag->length] = 0; > if (endptr != val) { > @@ -242,6 +239,11 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str) > return 3; > } > } > + > + if (resstr == NULL) { > + resstr = strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); > + } > + > /* the family and model entry is potentially split up across > * two fields in Fn0000_0001_EAX, so handle them here separately. > */ > -- > 1.7.10.4