Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various bug fixes #199

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcpuid/cpuid_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ hypervisor_vendor_t cpuid_get_hypervisor(struct cpu_raw_data_t* raw, struct cpu_
};

if (!data) {
if ((r = cpu_identify(raw, data)) < 0)
if ((r = cpu_identify(raw, &mydata)) < 0)
return HYPERVISOR_UNKNOWN;
data = &mydata;
}
TheTumultuousUnicornOfDarkness marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
7 changes: 5 additions & 2 deletions libcpuid/rdmsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct msr_driver_t* cpu_msr_driver_open_core(unsigned core_num)
handle = (struct msr_driver_t*) malloc(sizeof(struct msr_driver_t));
if (!handle) {
cpuid_set_error(ERR_NO_MEM);
close(fd);
return NULL;
}
handle->fd = fd;
Expand Down Expand Up @@ -1069,8 +1070,10 @@ int msr_serialize_raw_data(struct msr_driver_t* handle, const char* filename)

/* Get cached decoded CPUID information */
id = get_cached_cpuid();
if (id->vendor == VENDOR_UNKNOWN)
if (id->vendor == VENDOR_UNKNOWN) {
fclose(f);
return cpuid_get_error();
}

/* Get CPU stock speed */
if (cpu_clock == 0)
Expand All @@ -1082,7 +1085,7 @@ int msr_serialize_raw_data(struct msr_driver_t* handle, const char* filename)
case VENDOR_HYGON:
case VENDOR_AMD: msr = amd_msr; break;
case VENDOR_INTEL: msr = intel_msr; break;
default: return cpuid_set_error(ERR_CPU_UNKN);
default: fclose(f); return cpuid_set_error(ERR_CPU_UNKN);
}

/* Print raw MSR values */
Expand Down
2 changes: 1 addition & 1 deletion libcpuid/recog_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ static int decode_intel_extended_topology(struct cpu_raw_data_t* raw, struct cpu
{
int i, level_type, num_smt = -1, num_core = -1;

for (i = 0; (raw->intel_fn11[i][EAX] != 0x0) && (raw->intel_fn11[i][EBX] != 0x0) && (i < MAX_INTELFN11_LEVEL); i++) {
for (i = 0; (i < MAX_INTELFN11_LEVEL) && (raw->intel_fn11[i][EAX] != 0x0) && (raw->intel_fn11[i][EBX] != 0x0); i++) {
level_type = EXTRACTS_BITS(raw->intel_fn11[i][ECX], 15, 8);
switch (level_type) {
case 0x01:
Expand Down