From patchwork Tue Sep 29 11:00:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 291020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91534C4727F for ; Tue, 29 Sep 2020 11:57:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49809206CA for ; Tue, 29 Sep 2020 11:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601380630; bh=0VjeOJK4j5SEWqSkyC1NhqnZM/CZJA2MV+hP8yYojdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xWNn5dmDtOcDXkeaoRD0u367K95ct/eGVfyYf5rcPqLA49SblADlbt8/kDQZumJSL 8tJEftCHxk1nUWawmkriPxzWhJR1LnYDIiC/pPP55BKRj7hDYjhYsRfO66rRz8v/MA P72paxOIX3yiVUExxmqFgSw3nwQ/gZttWEhT0vE8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730779AbgI2Lni (ORCPT ); Tue, 29 Sep 2020 07:43:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:41062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730480AbgI2LnG (ORCPT ); Tue, 29 Sep 2020 07:43:06 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 0E5ED20702; Tue, 29 Sep 2020 11:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601379784; bh=0VjeOJK4j5SEWqSkyC1NhqnZM/CZJA2MV+hP8yYojdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QEByX0KfpGl9LVrA4/5i9neB4TJWrc2lCQ7CqXuNCS97nlWNl7iPa48FuNL5cai1j 2q0C9zHq0Siof+yvKQJVGYq8swsyPG+zvcdvLpcMDHQNsqjmUU91ANpe/uJXX1SMSn C9mbEbVGG8nUB0Dy93Oz0gXDtEvwQmH90aGDaGy8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xie XiuQi , Alexander Shishkin , Hongbo Yao , Jiri Olsa , Li Bin , Mark Rutland , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 286/388] perf util: Fix memory leak of prefix_if_not_in Date: Tue, 29 Sep 2020 13:00:17 +0200 Message-Id: <20200929110024.301774923@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929110010.467764689@linuxfoundation.org> References: <20200929110010.467764689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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;