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>] [day] [month] [year] [list]
Message-ID: <c69c79e4-04a3-4182-a694-809a5fa36083@web.de>
Date: Tue, 4 Mar 2025 10:50:35 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: kernel-janitors@...r.kernel.org, linux-perf-users@...r.kernel.org,
 Adrian Hunter <adrian.hunter@...el.com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Arnaldo Carvalho de Melo <acme@...nel.org>, Ian Rogers <irogers@...gle.com>,
 Ingo Molnar <mingo@...hat.com>, James Clark <james.clark@....com>,
 Jiri Olsa <jolsa@...nel.org>, Kan Liang <kan.liang@...ux.intel.com>,
 Leo Yan <leo.yan@...aro.org>, Mark Rutland <mark.rutland@....com>,
 Namhyung Kim <namhyung@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
 Suzuki Poulouse <suzuki.poulose@....com>
Cc: cocci@...ia.fr, LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH RESEND] perf cputopo: Improve exception handling in
 build_cpu_topology()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Thu, 23 Mar 2023 22:00:07 +0100

The label “done” was used to jump to another pointer check despite of
the detail in the implementation of the function “build_cpu_topology”
that it was determined already that a corresponding variable contained
a null pointer because of a failed call of the function “fopen”.

1. Thus use more appropriate labels instead.

2. Reorder jump targets at the end.

3. Delete a redundant check.


This issue was detected by using the Coccinelle software.

Fixes: 5135d5efcbb4 ("perf tools: Add cpu_topology object")
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 tools/perf/util/cputopo.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/cputopo.c b/tools/perf/util/cputopo.c
index e08797c3cdbc..fd185951ee2c 100644
--- a/tools/perf/util/cputopo.c
+++ b/tools/perf/util/cputopo.c
@@ -112,10 +112,10 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
 	}
 	fp = fopen(filename, "r");
 	if (!fp)
-		goto done;
+		goto exit;

 	if (getline(&buf, &len, fp) <= 0)
-		goto done;
+		goto close_file;

 	p = strchr(buf, '\n');
 	if (p)
@@ -131,10 +131,10 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
 		buf = NULL;
 	}
 	ret = 0;
-done:
-	if (fp)
-		fclose(fp);
 	free(buf);
+close_file:
+	fclose(fp);
+exit:
 	return ret;
 }

--
2.40.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ