lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240827164417.3309560-3-leo.yan@arm.com>
Date: Tue, 27 Aug 2024 17:44:10 +0100
From: Leo Yan <leo.yan@....com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
	Will Deacon <will@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Suzuki K Poulose <suzuki.poulose@....com>,
	Mike Leach <mike.leach@...aro.org>,
	James Clark <james.clark@...aro.org>,
	John Garry <john.g.garry@...cle.com>,
	Namhyung Kim <namhyung@...nel.org>,
	Ian Rogers <irogers@...gle.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	"Liang, Kan" <kan.liang@...ux.intel.com>,
	Jonathan Cameron <jonathan.cameron@...wei.com>,
	Yicong Yang <yangyicong@...ilicon.com>,
	linux-arm-kernel@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	coresight@...ts.linaro.org,
	linux-perf-users@...r.kernel.org
Cc: Leo Yan <leo.yan@....com>
Subject: [PATCH v1 2/9] perf auxtrace arm: Refactor error handling

Refactor the auxtrace_record__init() function to use a central place to
release resources and return value. This unifies the exit flow, and
allows the PMU arrays can be used throughout the function.

No functional changes; this is a preparation for sequential changes.

Signed-off-by: Leo Yan <leo.yan@....com>
---
 tools/perf/arch/arm/util/auxtrace.c | 35 ++++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/perf/arch/arm/util/auxtrace.c b/tools/perf/arch/arm/util/auxtrace.c
index 3b8eca0ffb17..74630d2d81dc 100644
--- a/tools/perf/arch/arm/util/auxtrace.c
+++ b/tools/perf/arch/arm/util/auxtrace.c
@@ -125,6 +125,7 @@ struct auxtrace_record
 	struct perf_pmu *found_etm = NULL;
 	struct perf_pmu *found_spe = NULL;
 	struct perf_pmu *found_ptt = NULL;
+	struct auxtrace_record *itr = NULL;
 	int auxtrace_event_cnt = 0;
 	int nr_spes = 0;
 	int nr_ptts = 0;
@@ -147,9 +148,6 @@ struct auxtrace_record
 			found_ptt = find_pmu_for_event(hisi_ptt_pmus, nr_ptts, evsel);
 	}
 
-	free(arm_spe_pmus);
-	free(hisi_ptt_pmus);
-
 	if (found_etm)
 		auxtrace_event_cnt++;
 
@@ -159,31 +157,36 @@ struct auxtrace_record
 	if (found_ptt)
 		auxtrace_event_cnt++;
 
-	if (auxtrace_event_cnt > 1) {
+	if (!auxtrace_event_cnt) {
+		/*
+		 * Clear 'err' even if we haven't found an event - that way perf
+		 * record can still be used even if tracers aren't present.
+		 * The NULL return value will take care of telling the
+		 * infrastructure HW tracing isn't available.
+		 */
+		*err = 0;
+		goto out;
+	} else if (auxtrace_event_cnt > 1) {
 		pr_err("Concurrent AUX trace operation not currently supported\n");
 		*err = -EOPNOTSUPP;
-		return NULL;
+		goto out;
 	}
 
 	if (found_etm)
-		return cs_etm_record_init(err);
+		itr = cs_etm_record_init(err);
 
 #if defined(__aarch64__)
 	if (found_spe)
-		return arm_spe_recording_init(err, found_spe);
+		itr = arm_spe_recording_init(err, found_spe);
 
 	if (found_ptt)
-		return hisi_ptt_recording_init(err, found_ptt);
+		itr = hisi_ptt_recording_init(err, found_ptt);
 #endif
 
-	/*
-	 * Clear 'err' even if we haven't found an event - that way perf
-	 * record can still be used even if tracers aren't present.  The NULL
-	 * return value will take care of telling the infrastructure HW tracing
-	 * isn't available.
-	 */
-	*err = 0;
-	return NULL;
+out:
+	free(arm_spe_pmus);
+	free(hisi_ptt_pmus);
+	return itr;
 }
 
 #if defined(__arm__)
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ