git: 494bc0464d90 - stable/15 - pmc(8): zero-initialize the event descriptor in stat mode

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 09 Nov 2026 16:07:05 UTC
The branch stable/15 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=494bc0464d90fb538cc0621710eb288855029e59

commit 494bc0464d90fb538cc0621710eb288855029e59
Author:     Andre Silva <andasilv@amd.com>
AuthorDate: 2026-11-05 13:54:31 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-11-09 16:06:46 +0000

    pmc(8): zero-initialize the event descriptor in stat mode
    
    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
    
    (cherry picked from commit a97914284c2e7a7dc330f4d93218e8d7f1e758b2)
---
 usr.sbin/pmc/cmd_pmc_stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;