Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1422233ybk; Thu, 21 May 2020 06:35:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+A4rr00U/VK6/ofE7Kwdn1kNauamhgOhPGiBRXfZwqVxE34MVdvAQFcPhmcLmsCMdnfg0 X-Received: by 2002:a17:906:951:: with SMTP id j17mr3490310ejd.352.1590068114469; Thu, 21 May 2020 06:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590068114; cv=none; d=google.com; s=arc-20160816; b=P4DLtgxJxm2iGCEw8rs1OraRckJuFWJlhoyI8NPH6R/mw6oyDJaclNwIpx1YlmZnVk jzIm/VjYtqpAa9UXpF+zrsGN+LPqOjm+GPgyPTpBM7suRm6Ha4bQs39s2aVeAcBy4Dt6 dmu/8AlRDT7+WPBawykca8zKzgY+aJ3OWUhxAQ2H3JbKUDbY7ZDNccGV+WWBrvp/dCOb 2Bf+6DcrKezTBEfCUsGfxoaOcBQJPuTe9zW+6as/7yNqwSQXWI9N9RZkUr0GQBAMUYrQ 1kYz8ztnsV4Ar8pYyuvA1Ot3L+lrOYg8GSUItHFgCfexeEEQ7EHZRGmbW/LRmdmgRFB8 NTmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=h0rRvHHQXgy1K03UvOvxJ2bfBDe956H78Zdarrrj350=; b=FwrxBarWSRsR40DmpXeVZcBooZ7clrpGJPPT9njVlhae2/nIbpArTJgMdXPl1Zl9SX EidMBBFzd1SZLFSF/iwSVNgG6KMTt+NJ9DV+XiUXXXgTmbKOa7fVOxn814FlpqVVVh7Z a26q7bO1+BkyPi7MvWyJf5geE7s0YnGgXEnly4F4WzjXQnRZJ1lPqByWKR0Yl+TJNnRl QqqXHA0tfNobkawUTqYZF+PisI0u1dKCv/KSy1AdLrbt1Ptf1ymPfViDUXUJfTgTY8oh Q2M6beuX2cJ/h/ToaldQACpbKntD8UV2B1lzZIMOc44ONW9srqVwk9YJP6Dv4gCXGca8 AO1A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si2840228ejb.189.2020.05.21.06.34.50; Thu, 21 May 2020 06:35:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729484AbgEUNdL (ORCPT + 99 others); Thu, 21 May 2020 09:33:11 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4880 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729362AbgEUNdK (ORCPT ); Thu, 21 May 2020 09:33:10 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 009C0D8D6EC6CD8FA4B6; Thu, 21 May 2020 21:33:09 +0800 (CST) Received: from euler.huawei.com (10.175.124.27) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Thu, 21 May 2020 21:32:57 +0800 From: Wei Li To: Alexander Shishkin , "Arnaldo Carvalho de Melo" , Jiri Olsa , Mark Rutland , Namhyung Kim CC: , Li Bin , "Xie XiuQi" , Hongbo Yao Subject: [PATCH 3/4] perf util: Fix memory leak of prefix_if_not_in Date: Thu, 21 May 2020 21:32:17 +0800 Message-ID: <20200521133218.30150-4-liwei391@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200521133218.30150-1-liwei391@huawei.com> References: <20200521133218.30150-1-liwei391@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie XiuQi Need to free "str" before return when asprintf() failed to avoid memory leak. 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