Skip to content

Commit 51cfe7a

Browse files
captain5050acmel
authored andcommitted
perf python: Avoid 2 leak sanitizer issues
Leak sanitizer complains about the variable size bf allocation and store to bf if sized 0. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ali Saidi <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Brian Robbins <[email protected]> Cc: Changbin Du <[email protected]> Cc: Dmitrii Dolgov <[email protected]> Cc: Fangrui Song <[email protected]> Cc: German Gomez <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Ivan Babrou <[email protected]> Cc: James Clark <[email protected]> Cc: Jing Zhang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: K Prateek Nayak <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Miguel Ojeda <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Naveen N. Rao <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Steinar H. Gunderson <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Wenyu Liu <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Ye Xingchen <[email protected]> Cc: Yuan Can <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent ac873ac commit 51cfe7a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/perf/util/scripting-engines/trace-event-python.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,9 @@ static void regs_map(struct regs_dump *regs, uint64_t mask, const char *arch, ch
735735
unsigned int i = 0, r;
736736
int printed = 0;
737737

738+
if (size <= 0)
739+
return;
740+
738741
bf[0] = 0;
739742

740743
if (!regs || !regs->regs)
@@ -764,7 +767,7 @@ static void set_regs_in_dict(PyObject *dict,
764767
* 10 chars is for register name.
765768
*/
766769
int size = __sw_hweight64(attr->sample_regs_intr) * 28;
767-
char bf[size];
770+
char *bf = malloc(size);
768771

769772
regs_map(&sample->intr_regs, attr->sample_regs_intr, arch, bf, sizeof(bf));
770773

@@ -775,6 +778,7 @@ static void set_regs_in_dict(PyObject *dict,
775778

776779
pydict_set_item_string_decref(dict, "uregs",
777780
_PyUnicode_FromString(bf));
781+
free(bf);
778782
}
779783

780784
static void set_sym_in_dict(PyObject *dict, struct addr_location *al,

0 commit comments

Comments
 (0)