summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Silva <andasilv@amd.com>2026-11-05 13:54:31 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2026-11-05 13:55:07 +0000
commita97914284c2e7a7dc330f4d93218e8d7f1e758b2 (patch)
treef1957abe2ce0bea9316e3e64cb69a01fc4e22a94
parentabd7dfa09a0ed1c06924226da0285d0731273f66 (diff)
pmc(8): zero-initialize the event descriptor in stat modehere
cmd_pmc_stat allocated the event descriptor with malloc and then set only some of its fields, so the rest held whatever was on the heap. Use calloc() instead. Reviewed by: mhorne MFC after: 3 days Sponsored by: AMD Signed-off-by: Andre Silva <andasilv@amd.com> Differential Revision: https://reviews.freebsd.org/D59364
-rw-r--r--usr.sbin/pmc/cmd_pmc_stat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.sbin/pmc/cmd_pmc_stat.c b/usr.sbin/pmc/cmd_pmc_stat.c
index 1e5c14e61857..719810a49b52 100644
--- a/usr.sbin/pmc/cmd_pmc_stat.c
+++ b/usr.sbin/pmc/cmd_pmc_stat.c
@@ -204,7 +204,7 @@ pmc_stat_setup_stat(int system_mode, const char *arg)
pmc_args.pa_logfd = pmcstat_open_log(pmc_args.pa_outputpath,
PMCSTAT_OPEN_FOR_WRITE);
for (i = 0; i < STAT_MODE_NPMCS; i++) {
- if ((ev = malloc(sizeof(*ev))) == NULL)
+ if ((ev = calloc(1, sizeof(*ev))) == NULL)
errx(EX_SOFTWARE, "ERROR: Out of memory.");
if (system_mode)
ev->ev_mode = PMC_MODE_SC;