Skip to content

Commit ef9c976

Browse files
authored
Really fix compilation; fix crash when pmodel is not present in cpuinfo
1 parent f727235 commit ef9c976

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cpuid_riscv64.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,21 @@ int detect(void){
8888
infile = fopen("/proc/cpuinfo", "r");
8989
while (fgets(buffer, sizeof(buffer), infile)){
9090
if(!strncmp(buffer, "model name", 10)){
91-
strcpy(model_buffer, buffer)
91+
strcpy(model_buffer, buffer);
9292
pmodel = strchr(isa_buffer, ':') + 1;
9393
}
9494

9595
if(!strncmp(buffer, "isa", 3)){
96-
strcpy(isa_buffer, buffer)
96+
strcpy(isa_buffer, buffer);
9797
pisa = strchr(isa_buffer, '4') + 1;
9898
}
9999
}
100100

101101
fclose(infile);
102102

103+
if (!pmodel)
104+
return(CPU_GENERIC);
105+
103106
if (strstr(pmodel, check_c910_str) && strchr(pisa, 'v'))
104107
return CPU_C910V;
105108

0 commit comments

Comments
 (0)