Skip to content

Commit 6ec9503

Browse files
captain5050acmel
authored andcommitted
perf parse-events: Avoid string for PE_BP_COLON, PE_BP_SLASH
There's no need to read the string ':' or '/' for PE_BP_COLON or PE_BP_SLASH and doing so causes parse-events.y to leak memory. The original patch has a committer note about not using these tokens presumably as yacc spotted they were a memory leak because no %destructor could be run. Remove the unused token workaround as there is now no value associated with these tokens. Fixes: f0617f5 ("perf parse: Allow config terms with breakpoints") Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20230613182629.1500317-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent e4c4e8a commit 6ec9503

File tree

3 files changed

+2
-15
lines changed

3 files changed

+2
-15
lines changed

tools/perf/util/parse-events.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@ void parse_events_error__handle(struct parse_events_error *err, int idx,
228228
void parse_events_error__print(struct parse_events_error *err,
229229
const char *event);
230230

231-
static inline void parse_events_unused_value(const void *x __maybe_unused)
232-
{
233-
}
234-
235231
#ifdef HAVE_LIBELF_SUPPORT
236232
/*
237233
* If the probe point starts with '%',

tools/perf/util/parse-events.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ r0x{num_raw_hex} { return str(yyscanner, PE_RAW); }
315315
* are the same, so trailing context can be used disambiguate the two
316316
* cases.
317317
*/
318-
":"/{modifier_bp} { return str(yyscanner, PE_BP_COLON); }
318+
":"/{modifier_bp} { return PE_BP_COLON; }
319319
/*
320320
* The slash before memory length can get mixed up with the slash before
321321
* config terms. Fortunately config terms do not start with a numeric
322322
* digit, so trailing context can be used disambiguate the two cases.
323323
*/
324-
"/"/{digit} { return str(yyscanner, PE_BP_SLASH); }
324+
"/"/{digit} { return PE_BP_SLASH; }
325325
"/"/{non_digit} { BEGIN(config); return '/'; }
326326
{num_dec} { return value(yyscanner, 10); }
327327
{num_hex} { return value(yyscanner, 16); }

tools/perf/util/parse-events.y

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ static void free_list_evsel(struct list_head* list_evsel)
8080
%type <str> PE_LEGACY_CACHE
8181
%type <str> PE_MODIFIER_EVENT
8282
%type <str> PE_MODIFIER_BP
83-
%type <str> PE_BP_COLON
84-
%type <str> PE_BP_SLASH
8583
%type <str> PE_EVENT_NAME
8684
%type <str> PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
8785
%type <str> PE_DRV_CFG_TERM
@@ -510,9 +508,6 @@ PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE PE_BP_COLON PE_MODIFIER_BP opt_event
510508
struct list_head *list;
511509
int err;
512510

513-
parse_events_unused_value(&$3);
514-
parse_events_unused_value(&$5);
515-
516511
list = alloc_list();
517512
ABORT_ON(!list);
518513
err = parse_events_add_breakpoint(_parse_state, list,
@@ -531,8 +526,6 @@ PE_PREFIX_MEM PE_VALUE PE_BP_SLASH PE_VALUE opt_event_config
531526
struct list_head *list;
532527
int err;
533528

534-
parse_events_unused_value(&$3);
535-
536529
list = alloc_list();
537530
ABORT_ON(!list);
538531
err = parse_events_add_breakpoint(_parse_state, list,
@@ -550,8 +543,6 @@ PE_PREFIX_MEM PE_VALUE PE_BP_COLON PE_MODIFIER_BP opt_event_config
550543
struct list_head *list;
551544
int err;
552545

553-
parse_events_unused_value(&$3);
554-
555546
list = alloc_list();
556547
ABORT_ON(!list);
557548
err = parse_events_add_breakpoint(_parse_state, list,

0 commit comments

Comments
 (0)