Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3289314pxk; Mon, 21 Sep 2020 09:47:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGM2MPG6W1AzjDGoC8zhu9BQQeNW+ORY6l7fwW/o7OXZXT2/N2b3olGfpeEg/qYD+VqMFj X-Received: by 2002:a17:906:56c2:: with SMTP id an2mr380338ejc.118.1600706865563; Mon, 21 Sep 2020 09:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706865; cv=none; d=google.com; s=arc-20160816; b=PTNSM8qRaSH33cSF+UHmuw1509nm69Aa0wtDuNzyfKQ44n2hW9xn2YmPEl7541T6YH JiGayXtIcVBsqvV+qWrvXPDTxn4XqSDceJmacjG25yJNoXORJM6Mko7v912d1Sv1THjB 6C2FhDtV8eVXGlC7DgOWmj670/ecL37EJgZGwwYkLgFkbx/r8FtVc6r/Cjb2dFb5b2PS EFdIm53hD2QZfaLePK6XMr1FSssSkc1j8eZ4I3l1wS/taiyuuyry05QMQmZdfvlL2FpN 0P6BbT77fv6h1CUV+byw/C6PYsaj8JGv1R9+61b05zwbiYI9OxY6nQd1BV8Q568OZAL7 Re0g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PldTx/iToaFHQogthojSYWs+UioFTvzMcEa4YsEJggw=; b=OwjCP7xoJT/xUjZoPjeJZ6UjPHHJJHlOkLPV/TNdws+q3NzN0P0qRoPm7rqzW4oMFl f8b22HWqfVYU4Tnj9NLEfoIhWK37gizeJjPSYZkTET+JLBuro0uuMxsEGWylFvhTz44w qeRtVUPQY3DjHa5EYseuPCSakvDv+3DpDnWRwwVLz5o+il90zWmCq7MuZZXuqngugqEW 9a069ukNuPHxLDKdtX2lzqcKr6Qqp0O6mzAWCH9kkgcYbCml3CekeRcThi0Djvc87u5J 7oUVR94mzwP+tC8vltBLL25ESRVkOSqT3PqgSwqAexz7hCw+7f47p7nUb8s6OiHzqdO+ 9Hlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KheTFHJm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt7si8289961ejb.694.2020.09.21.09.47.21; Mon, 21 Sep 2020 09:47:45 -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=KheTFHJm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729498AbgIUQq0 (ORCPT + 99 others); Mon, 21 Sep 2020 12:46:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:52580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729619AbgIUQqY (ORCPT ); Mon, 21 Sep 2020 12:46:24 -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 622FB23788; Mon, 21 Sep 2020 16:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706782; bh=UaGrN3/d07rZKCwNS9IvXoK3V5f0g30w/n3G1l2oOtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KheTFHJmhEp0xq+JaItQMdZiKPlO3MKN4hj386VyYfSxmI16KW+cMd2CHRW41rXsk rD+AjFtALjmCU0X3bV6YD8UaMfqIRzHvOfFNqM4rQSoicRTBMQB02y2EhJAfQUMqUS 9/0xZT3BXS9SzM653fA55DJZDKFiRORxFhuv52tw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , Jiri Olsa , Alexander Shishkin , Andi Kleen , Ian Rogers , Mark Rutland , Peter Zijlstra , Stephane Eranian , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.8 063/118] perf test: Free formats for perf pmu parse test Date: Mon, 21 Sep 2020 18:27:55 +0200 Message-Id: <20200921162039.285148012@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Namhyung Kim [ Upstream commit d26383dcb2b4b8629fde05270b4e3633be9e3d4b ] The following leaks were detected by ASAN: Indirect leak of 360 byte(s) in 9 object(s) allocated from: #0 0x7fecc305180e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10780e) #1 0x560578f6dce5 in perf_pmu__new_format util/pmu.c:1333 #2 0x560578f752fc in perf_pmu_parse util/pmu.y:59 #3 0x560578f6a8b7 in perf_pmu__format_parse util/pmu.c:73 #4 0x560578e07045 in test__pmu tests/pmu.c:155 #5 0x560578de109b in run_test tests/builtin-test.c:410 #6 0x560578de109b in test_and_print tests/builtin-test.c:440 #7 0x560578de401a in __cmd_test tests/builtin-test.c:661 #8 0x560578de401a in cmd_test tests/builtin-test.c:807 #9 0x560578e49354 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312 #10 0x560578ce71a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364 #11 0x560578ce71a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408 #12 0x560578ce71a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538 #13 0x7fecc2b7acc9 in __libc_start_main ../csu/libc-start.c:308 Fixes: cff7f956ec4a1 ("perf tests: Move pmu tests into separate object") Signed-off-by: Namhyung Kim Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ian Rogers Cc: Mark Rutland Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lore.kernel.org/lkml/20200915031819.386559-12-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/pmu.c | 1 + tools/perf/util/pmu.c | 11 +++++++++++ tools/perf/util/pmu.h | 1 + 3 files changed, 13 insertions(+) diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c index 5c11fe2b30406..714e6830a758f 100644 --- a/tools/perf/tests/pmu.c +++ b/tools/perf/tests/pmu.c @@ -173,6 +173,7 @@ int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused) ret = 0; } while (0); + perf_pmu__del_formats(&formats); test_format_dir_put(format); return ret; } diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 97882e55321fe..483da97ac4459 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1352,6 +1352,17 @@ void perf_pmu__set_format(unsigned long *bits, long from, long to) set_bit(b, bits); } +void perf_pmu__del_formats(struct list_head *formats) +{ + struct perf_pmu_format *fmt, *tmp; + + list_for_each_entry_safe(fmt, tmp, formats, list) { + list_del(&fmt->list); + free(fmt->name); + free(fmt); + } +} + static int sub_non_neg(int a, int b) { if (b > a) diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 1db31cbd21887..28778b47fb4b7 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -92,6 +92,7 @@ int perf_pmu__new_format(struct list_head *list, char *name, int config, unsigned long *bits); void perf_pmu__set_format(unsigned long *bits, long from, long to); int perf_pmu__format_parse(char *dir, struct list_head *head); +void perf_pmu__del_formats(struct list_head *formats); struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu); -- 2.25.1