Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853975pxk; Thu, 17 Sep 2020 19:09:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEK/1VXQGO79HtUa75kH+WxgtrIeQuzrWVt9PsdkUB0e8MYEMf0/4NKxGxSXPqDNtXG1qs X-Received: by 2002:a05:6402:176c:: with SMTP id da12mr36937505edb.386.1600394986127; Thu, 17 Sep 2020 19:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394986; cv=none; d=google.com; s=arc-20160816; b=PHB+Sg+01ZT6eHvgmwDQ+VFv+/n/Ct+inAKJFFyIw1iLwLVZyHV0Fah2/zWjXInl50 GWqA0RSN6KOsqOOEpLqAOvDS6Muh5O8SaX5Qiix8bKowlve/ENV5AXsjb0mgVcUF9rUI euBYVel4NvTG+BtbiIFJZi71AgvLCJo7w0K6WGEPeDFXa2vIcLTV+uERnRexmT8U4bki WEa+hg2vez08JdaySnPODV928ntM215MEUCxWdb1cwztyUKXqTgRyrtb8OdtRdlnr3qP M+8T3V7FX2ZRt4ROS0F17dWJUS9+4w2EHdJfa8jLtBr9pLbmy412xdqn4WLcsB37o/TE NInw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uK79mbu0b+GoBz+HoFFDeIj6g/i6VqChci3EVk8kYqk=; b=l6Jzy52KYNij5DU3Z2Z8lurid0EevQUvwE3OgzcTWR2DMMuOoMno1Ga61tgFmhcCOC suBrJhJcmxr4/rIls/WLARcAh7OMfcn42VFlEPc02gkQiEvbSpfL/nQ+EmvXNty8eBae cVHcE6gUF10lp6B2FrH9m6kS7gg+G3mqQSs4GSg7dMCn39VPGweWusbzQdzQ4Bi8DDpO B65/E2sBHVP2PWr8DHBxnVCHAsU0C2AEev8Luj+5Po8D+YaHfuBKrKVYCAChtDkQYLPB TzX5zzkbII73ynvBwMnH2ViDgZSn4Ut6FshEhW/OOf0KjLNZWcK9oVm44wYxsvyUUxUv 7BJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lq5gOtMX; 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 a14si1137719edk.57.2020.09.17.19.09.22; Thu, 17 Sep 2020 19:09:46 -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=lq5gOtMX; 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 S1727903AbgIRCHV (ORCPT + 99 others); Thu, 17 Sep 2020 22:07:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:57400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbgIRCHO (ORCPT ); Thu, 17 Sep 2020 22:07:14 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 21C70238A1; Fri, 18 Sep 2020 02:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394834; bh=0VjeOJK4j5SEWqSkyC1NhqnZM/CZJA2MV+hP8yYojdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lq5gOtMXPeNLhoXAL/46TkSoa7+lsTmOiggyggh534PqeF5M8pzgU/yP16mTYlAaz 9/i6u0u754u3nU6CdvYg3wYOTVpxTAmtndj8f7+9kwmcjRWjkbBKMtwFInnB8RkK0+ LCH6LYyrBGOPuj1lbROQ/cN6hcDyf5U4awz64wfc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xie XiuQi , Alexander Shishkin , Hongbo Yao , Jiri Olsa , Li Bin , Mark Rutland , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 5.4 295/330] perf util: Fix memory leak of prefix_if_not_in Date: Thu, 17 Sep 2020 22:00:35 -0400 Message-Id: <20200918020110.2063155-295-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie XiuQi [ Upstream commit 07e9a6f538cbeecaf5c55b6f2991416f873cdcbd ] Need to free "str" before return when asprintf() failed to avoid memory leak. Signed-off-by: Xie XiuQi Cc: Alexander Shishkin Cc: Hongbo Yao Cc: Jiri Olsa Cc: Li Bin Cc: Mark Rutland Cc: Namhyung Kim Link: http://lore.kernel.org/lkml/20200521133218.30150-4-liwei391@huawei.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- 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 43d1d410854a3..4027906fd3e38 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2788,7 +2788,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.25.1