Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1471837ybk; Thu, 21 May 2020 07:40:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyB/RfEjWg39qbqNZbsvfU/wOaWeDzKXW98tJ+nACMduB6+Mp+oXjreT07TZXJITeZ97OwI X-Received: by 2002:a17:906:509:: with SMTP id j9mr3717957eja.152.1590072051996; Thu, 21 May 2020 07:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590072051; cv=none; d=google.com; s=arc-20160816; b=PJiMDKzGXh7wJO+cfbY+8v1aMK3kWST6rkd0o0oiUsUSGvaTuqvqj9FzmkWMJV0+7a GofMSfQbPmBalijLvwwW7GklGvmA9DsDadydhN3SR+ffbHJOqNGjH5GsW9lRjUJSlowg Vkw9bKDJGC5cMlges/vuQCNWgtsLRBLqA7J7ETAaWR5PBwsuJUtK1+AJYudCdR/qJLBs KYe3QhxyOTHkuRZrI41dCASsxfG/sCNUY0Jqf2EaKSWBHUIyBPr60cISjrxRtDt1V5mP 8PXJB5y2o/r5lXFoDFdtU6CH94/sSdtCc11Z+j1TCCRvJ/PACP4dnuz0Px0HoTM8alqE RDlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=0xOnDhlXFChsimTyr2jhxNy4WDEPwpp8Ca+/hLqWDvQ=; b=Ah9seiLiXZaXQ+AJHbenKElUjyUjmOBsWpR/vO37N3hcT8sj2MFdHHklbu2/zCqg3N 7Wzz8Xa2m4UMUnDnrB6OufM5wvKzlTwt8Zj1KXRhG38dypD3iloIqIxLzIJQ9oUI746v IMdWkHQLvKxVLhwIGxKRnfJjpEEo9Amn+iXcrZLNCViLt9QdzJTNx2yA1j7e0UZTL9H9 wNZtl6ySPMgbJ9b1anbGapZ3zJI3BECE+Yrw+tRKkqpROEzsjQcE063KTYYupyarX0te zf06PYRFmleuod/mKrLyqn5tyaKWWo53KwLvh/3ChmgWADz9+FP/w4OuQaiULWdoj2/i aZ4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=woHkGv73; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si3280593edj.601.2020.05.21.07.40.28; Thu, 21 May 2020 07:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=woHkGv73; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728255AbgEUOjI (ORCPT + 99 others); Thu, 21 May 2020 10:39:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:44106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbgEUOjH (ORCPT ); Thu, 21 May 2020 10:39:07 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CCDC20671; Thu, 21 May 2020 14:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590071946; bh=AUrIYszsGcTlofI5OitFwXmvXCOlSVlZDrQb5lN3o+k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=woHkGv73Kt4bS5VdJBXEs0MT6SuWBINUqq1MxivFRNo80V/vHPzCJQIQCU7fA217c iF7tX83CvNz9F5EKBwPScl85q2TdC7ajxjC3vVJ+P99vAV9r/l59ydpuxKYg8ynScK wtfaK4OeMwserxQpOSjAqRuCGvcl2eCj+jW/eJvw= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id A822A40AFD; Thu, 21 May 2020 11:39:03 -0300 (-03) Date: Thu, 21 May 2020 11:39:03 -0300 From: Arnaldo Carvalho de Melo To: Wei Li Cc: Alexander Shishkin , Jiri Olsa , Mark Rutland , Namhyung Kim , linux-kernel@vger.kernel.org, Li Bin , Xie XiuQi , Hongbo Yao Subject: Re: [PATCH 3/4] perf util: Fix memory leak of prefix_if_not_in Message-ID: <20200521143903.GD3898@kernel.org> References: <20200521133218.30150-1-liwei391@huawei.com> <20200521133218.30150-4-liwei391@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521133218.30150-4-liwei391@huawei.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, May 21, 2020 at 09:32:17PM +0800, Wei Li escreveu: > From: Xie XiuQi > > Need to free "str" before return when asprintf() failed > to avoid memory leak. Thanks, applied. - Arnaldo > Signed-off-by: Xie XiuQi > --- > tools/perf/util/sort.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c > index f14cc728c358..8ed777565c82 100644 > --- a/tools/perf/util/sort.c > +++ b/tools/perf/util/sort.c > @@ -2811,7 +2811,7 @@ static char *prefix_if_not_in(const char *pre, char *str) > return str; > > if (asprintf(&n, "%s,%s", pre, str) < 0) > - return NULL; > + n = NULL; > > free(str); > return n; > -- > 2.17.1 > -- - Arnaldo