linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] perf pmu: Ensure all alias variables are initialized
@ 2023-09-14  2:24 Ian Rogers
  2023-09-17  5:27 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2023-09-14  2:24 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Kan Liang, James Clark,
	linux-perf-users, linux-kernel

Fix an error detected by memory sanitizer:
```
==4033==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55fb0fbedfc7 in read_alias_info tools/perf/util/pmu.c:457:6
    #1 0x55fb0fbea339 in check_info_data tools/perf/util/pmu.c:1434:2
    #2 0x55fb0fbea339 in perf_pmu__check_alias tools/perf/util/pmu.c:1504:9
    #3 0x55fb0fbdca85 in parse_events_add_pmu tools/perf/util/parse-events.c:1429:32
    #4 0x55fb0f965230 in parse_events_parse tools/perf/util/parse-events.y:299:6
    #5 0x55fb0fbdf6b2 in parse_events__scanner tools/perf/util/parse-events.c:1822:8
    #6 0x55fb0fbdf8c1 in __parse_events tools/perf/util/parse-events.c:2094:8
    #7 0x55fb0fa8ffa9 in parse_events tools/perf/util/parse-events.h:41:9
    #8 0x55fb0fa8ffa9 in test_event tools/perf/tests/parse-events.c:2393:8
    #9 0x55fb0fa8f458 in test__pmu_events tools/perf/tests/parse-events.c:2551:15
    #10 0x55fb0fa6d93f in run_test tools/perf/tests/builtin-test.c:242:9
    #11 0x55fb0fa6d93f in test_and_print tools/perf/tests/builtin-test.c:271:8
    #12 0x55fb0fa6d082 in __cmd_test tools/perf/tests/builtin-test.c:442:5
    #13 0x55fb0fa6d082 in cmd_test tools/perf/tests/builtin-test.c:564:9
    #14 0x55fb0f942720 in run_builtin tools/perf/perf.c:322:11
    #15 0x55fb0f942486 in handle_internal_command tools/perf/perf.c:375:8
    #16 0x55fb0f941dab in run_argv tools/perf/perf.c:419:2
    #17 0x55fb0f941dab in main tools/perf/perf.c:535:3
```

Fixes: 7b723dbb96e8 ("perf pmu: Be lazy about loading event info files
from sysfs")

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d85602aa4b9f..8de6f39abd1b 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -520,7 +520,7 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, const char *name,
 		pmu_name = pe->pmu;
 	}
 
-	alias = malloc(sizeof(*alias));
+	alias = zalloc(sizeof(*alias));
 	if (!alias)
 		return -ENOMEM;
 
-- 
2.42.0.459.ge4e396fd5e-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] perf pmu: Ensure all alias variables are initialized
  2023-09-14  2:24 [PATCH v1] perf pmu: Ensure all alias variables are initialized Ian Rogers
@ 2023-09-17  5:27 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2023-09-17  5:27 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
	Kan Liang, James Clark, linux-perf-users, linux-kernel

On Wed, Sep 13, 2023 at 7:24 PM Ian Rogers <irogers@google.com> wrote:
>
> Fix an error detected by memory sanitizer:
> ```
> ==4033==WARNING: MemorySanitizer: use-of-uninitialized-value
>     #0 0x55fb0fbedfc7 in read_alias_info tools/perf/util/pmu.c:457:6
>     #1 0x55fb0fbea339 in check_info_data tools/perf/util/pmu.c:1434:2
>     #2 0x55fb0fbea339 in perf_pmu__check_alias tools/perf/util/pmu.c:1504:9
>     #3 0x55fb0fbdca85 in parse_events_add_pmu tools/perf/util/parse-events.c:1429:32
>     #4 0x55fb0f965230 in parse_events_parse tools/perf/util/parse-events.y:299:6
>     #5 0x55fb0fbdf6b2 in parse_events__scanner tools/perf/util/parse-events.c:1822:8
>     #6 0x55fb0fbdf8c1 in __parse_events tools/perf/util/parse-events.c:2094:8
>     #7 0x55fb0fa8ffa9 in parse_events tools/perf/util/parse-events.h:41:9
>     #8 0x55fb0fa8ffa9 in test_event tools/perf/tests/parse-events.c:2393:8
>     #9 0x55fb0fa8f458 in test__pmu_events tools/perf/tests/parse-events.c:2551:15
>     #10 0x55fb0fa6d93f in run_test tools/perf/tests/builtin-test.c:242:9
>     #11 0x55fb0fa6d93f in test_and_print tools/perf/tests/builtin-test.c:271:8
>     #12 0x55fb0fa6d082 in __cmd_test tools/perf/tests/builtin-test.c:442:5
>     #13 0x55fb0fa6d082 in cmd_test tools/perf/tests/builtin-test.c:564:9
>     #14 0x55fb0f942720 in run_builtin tools/perf/perf.c:322:11
>     #15 0x55fb0f942486 in handle_internal_command tools/perf/perf.c:375:8
>     #16 0x55fb0f941dab in run_argv tools/perf/perf.c:419:2
>     #17 0x55fb0f941dab in main tools/perf/perf.c:535:3
> ```
>
> Fixes: 7b723dbb96e8 ("perf pmu: Be lazy about loading event info files
> from sysfs")
>
> Signed-off-by: Ian Rogers <irogers@google.com>

Applied to perf-tools, thanks!

Namhyung

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-17  5:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14  2:24 [PATCH v1] perf pmu: Ensure all alias variables are initialized Ian Rogers
2023-09-17  5:27 ` Namhyung Kim

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).