Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140113312
D25679.id74489.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D25679.id74489.diff
View Options
Index: lib/libpmc/libpmc_pmu_util.c
===================================================================
--- lib/libpmc/libpmc_pmu_util.c
+++ lib/libpmc/libpmc_pmu_util.c
@@ -30,6 +30,7 @@
#include <sys/types.h>
#include <sys/errno.h>
+#include <sys/pmc.h>
#include <sys/sysctl.h>
#include <stddef.h>
#include <stdlib.h>
@@ -89,20 +90,13 @@
static pmu_mfr_t
pmu_events_mfr(void)
{
- char *buf;
- size_t s;
+ char buf[PMC_CPUID_LEN];
+ size_t s = sizeof(buf);
pmu_mfr_t mfr;
- if (sysctlbyname("kern.hwpmc.cpuid", (void *)NULL, &s,
- (void *)NULL, 0) == -1)
- return (PMU_INVALID);
- if ((buf = malloc(s + 1)) == NULL)
- return (PMU_INVALID);
if (sysctlbyname("kern.hwpmc.cpuid", buf, &s,
- (void *)NULL, 0) == -1) {
- free(buf);
+ (void *)NULL, 0) == -1)
return (PMU_INVALID);
- }
if (strcasestr(buf, "AuthenticAMD") != NULL ||
strcasestr(buf, "HygonGenuine") != NULL)
mfr = PMU_AMD;
@@ -110,7 +104,6 @@
mfr = PMU_INTEL;
else
mfr = PMU_INVALID;
- free(buf);
return (mfr);
}
@@ -169,17 +162,14 @@
{
regex_t re;
regmatch_t pmatch[1];
- size_t s;
- char buf[64];
+ char buf[PMC_CPUID_LEN];
+ size_t s = sizeof(buf);
int match;
const struct pmu_events_map *pme;
if (cpuid != NULL) {
- memcpy(buf, cpuid, 64);
+ strlcpy(buf, cpuid, s);
} else {
- if (sysctlbyname("kern.hwpmc.cpuid", (void *)NULL, &s,
- (void *)NULL, 0) == -1)
- return (NULL);
if (sysctlbyname("kern.hwpmc.cpuid", buf, &s,
(void *)NULL, 0) == -1)
return (NULL);
Index: sys/dev/hwpmc/hwpmc_mod.c
===================================================================
--- sys/dev/hwpmc/hwpmc_mod.c
+++ sys/dev/hwpmc/hwpmc_mod.c
@@ -305,7 +305,7 @@
SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_RDTUN,
&pmc_callchaindepth, 0, "depth of call chain records");
-char pmc_cpuid[64];
+char pmc_cpuid[PMC_CPUID_LEN];
SYSCTL_STRING(_kern_hwpmc, OID_AUTO, cpuid, CTLFLAG_RD,
pmc_cpuid, 0, "cpu version string");
#ifdef HWPMC_DEBUG
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 21, 10:10 AM (4 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27111239
Default Alt Text
D25679.id74489.diff (1 KB)
Attached To
Mode
D25679: libpmc: Use known pmc_cpuid buffer size
Attached
Detach File
Event Timeline
Log In to Comment