Message ID | 20231207081635.8427-3-yangyicong@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4628418vqy; Thu, 7 Dec 2023 00:22:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGurFvZSvwBO1H/bLNaQyiiYz/6XUK8ykUSZnI/49NCV+3qKvjXmhm3rpTgM8vRcKYgfYc1 X-Received: by 2002:a17:902:d301:b0:1d0:acf9:f45b with SMTP id b1-20020a170902d30100b001d0acf9f45bmr1986314plc.135.1701937334263; Thu, 07 Dec 2023 00:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701937334; cv=none; d=google.com; s=arc-20160816; b=bL5W3EwO/RQhVlwwtQ77keaf5/gUEZjdXTtQJruJnotiyEfLR2PD4g3K40KET+ijjK FOm9GDuBOxR0vuncoDKBCS4cQe/ttCFb1TO0gULbqdz1RHXlfmCOWosQnsEwr43TSX4D pzDHzqrikihEk/rMpru1lKYP3OPAu5F4a7qyhGcen1wuACzGXqZrANKDnAX4tBhs+kqD y9XC2zgEy9w93x0E76kG1384XN3lFdTMuJrHSKRJGi1XTi5SUoBq2qURCL4MmE/ZPsb1 C5VRENtLiOVVa6T7apHy7Bt3c+Facuc9PQuJfsJpzJbWIX2qvsrOR0c9EzVu9a4SFt7j 1eHQ== 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; bh=iesPq3HcqaI2YSNevRCTph9mFOv6dmjQ5O0wlQYX1uw=; fh=K06Jco0a5Hd2X5wdXGCplGw8z+4vmGZK/avjKpeDM8o=; b=GVvZyVvSNH/GkdI9xFe2sONLx/+ietpQkrE/re7w4BvGI8o0b87neB46u9zFh5NXxz 2g80Ee5OUpI5K1tEWz4Wz86/BV4VVGojO3kTBvt6F1djImsIs91T0NQ5/FDD0Pvjx/uk PWy3xJOx4VN9jdx+LbCF44CU8JJj1kb0NNiC85Gx3+MGOL00WCijVENG2WO5IUVEoK4C 5J1eI/u2lsiCr2jvJIhwiEte1bGJqWImNegMiLTapDVHIuPd8b4LTYKqVPC0GD7/sSJG LVINDT8WaeANuoDDjxp1dz33pbdYJgWWXQqCZvL62UFa7fUtW9q9lKNzMzkEbOk9P2ZV 8OGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w13-20020a170902a70d00b001cfd0ddc5d6si710134plq.348.2023.12.07.00.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 00:22:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E244880755DA; Thu, 7 Dec 2023 00:21:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbjLGIU5 (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Thu, 7 Dec 2023 03:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231876AbjLGIUV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 7 Dec 2023 03:20:21 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4299410DB; Thu, 7 Dec 2023 00:20:24 -0800 (PST) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Sm6Xw0KSszShmK; Thu, 7 Dec 2023 16:16:00 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 7 Dec 2023 16:20:22 +0800 From: Yicong Yang <yangyicong@huawei.com> To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>, <mark.rutland@arm.com>, <alexander.shishkin@linux.intel.com>, <jolsa@kernel.org>, <namhyung@kernel.org>, <irogers@google.com>, <adrian.hunter@intel.com>, <linux-perf-users@vger.kernel.org>, <linux-kernel@vger.kernel.org> CC: <jonathan.cameron@huawei.com>, <hejunhao3@huawei.com>, <yangyicong@hisilicon.com>, <linuxarm@huawei.com> Subject: [PATCH 2/2] perf hisi-ptt: Fix one memory leakage in hisi_ptt_process_auxtrace_event() Date: Thu, 7 Dec 2023 16:16:35 +0800 Message-ID: <20231207081635.8427-3-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231207081635.8427-1-yangyicong@huawei.com> References: <20231207081635.8427-1-yangyicong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 00:21:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784610641870349566 X-GMAIL-MSGID: 1784610641870349566 |
Series |
Perf fix two memory leakage
|
|
Commit Message
Yicong Yang
Dec. 7, 2023, 8:16 a.m. UTC
From: Yicong Yang <yangyicong@hisilicon.com> ASan complains a memory leakage in hisi_ptt_process_auxtrace_event() that the data buffer is not freed. Since currently we only support the raw dump trace mode, the data buffer is used only within this function. So fix this by freeing the data buffer before going out. Fixes: 5e91e57e6809 ("perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet") Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> --- tools/perf/util/hisi-ptt.c | 1 + 1 file changed, 1 insertion(+)
Comments
On Thu, Dec 7, 2023 at 12:20 AM Yicong Yang <yangyicong@huawei.com> wrote: > > From: Yicong Yang <yangyicong@hisilicon.com> > > ASan complains a memory leakage in hisi_ptt_process_auxtrace_event() > that the data buffer is not freed. Since currently we only support > the raw dump trace mode, the data buffer is used only within this > function. So fix this by freeing the data buffer before going out. > > Fixes: 5e91e57e6809 ("perf auxtrace arm64: Add support for parsing HiSilicon PCIe Trace packet") > Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Acked-by: Namhyung Kim <Namhyung@kernel.org> Thanks, Namhyung > --- > tools/perf/util/hisi-ptt.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c > index 43bd1ca62d58..52d0ce302ca0 100644 > --- a/tools/perf/util/hisi-ptt.c > +++ b/tools/perf/util/hisi-ptt.c > @@ -123,6 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session, > if (dump_trace) > hisi_ptt_dump_event(ptt, data, size); > > + free(data); > return 0; > } > > -- > 2.24.0 > >
diff --git a/tools/perf/util/hisi-ptt.c b/tools/perf/util/hisi-ptt.c index 43bd1ca62d58..52d0ce302ca0 100644 --- a/tools/perf/util/hisi-ptt.c +++ b/tools/perf/util/hisi-ptt.c @@ -123,6 +123,7 @@ static int hisi_ptt_process_auxtrace_event(struct perf_session *session, if (dump_trace) hisi_ptt_dump_event(ptt, data, size); + free(data); return 0; }