linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]  perf tools: Fix regcomp() error detection in SDT probes
@ 2025-09-02  6:43 Kaushlendra Kumar
  0 siblings, 0 replies; only message in thread
From: Kaushlendra Kumar @ 2025-09-02  6:43 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, jolsa; +Cc: linux-perf-users, Kaushlendra Kumar

The regcomp() function returns 0 on success and a non-zero error code
on failure, not negative values. The current code incorrectly checks
for ret < 0, which would miss positive error codes returned by regcomp().

Fix the error checking in sdt_init_op_regex() and arch_sdt_arg_parse_op()
to properly check for non-zero return values using ret != 0, ensuring
all regcomp() failures are correctly detected and handled.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 tools/perf/arch/x86/util/perf_regs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/arch/x86/util/perf_regs.c b/tools/perf/arch/x86/util/perf_regs.c
index 12fd93f04802..1e9967a98889 100644
--- a/tools/perf/arch/x86/util/perf_regs.c
+++ b/tools/perf/arch/x86/util/perf_regs.c
@@ -156,7 +156,7 @@ static int sdt_init_op_regex(void)
 		return 0;
 
 	ret = regcomp(&sdt_op_regex, SDT_OP_REGEX, REG_EXTENDED);
-	if (ret < 0) {
+	if (ret != 0) {
 		pr_debug4("Regex compilation error.\n");
 		return ret;
 	}
@@ -215,7 +215,7 @@ int arch_sdt_arg_parse_op(char *old_op, char **new_op)
 	char prefix[3] = {0};
 
 	ret = sdt_init_op_regex();
-	if (ret < 0)
+	if (ret != 0)
 		return ret;
 
 	/*
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-02  6:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02  6:43 [PATCH] perf tools: Fix regcomp() error detection in SDT probes Kaushlendra Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).