git: 0ab6ce9f1813 - stable/14 - pmc(8): zero-initialize the event descriptor in stat mode
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 Nov 2026 16:08:46 UTC
The branch stable/14 has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=0ab6ce9f18130f8c68646b242e5df9a35f9a3301
commit 0ab6ce9f18130f8c68646b242e5df9a35f9a3301
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:08:03 +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 659b36137724..a84aa30bc8be 100644
--- a/usr.sbin/pmc/cmd_pmc_stat.c
+++ b/usr.sbin/pmc/cmd_pmc_stat.c
@@ -205,7 +205,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;