Skip to content

Commit f29389c

Browse files
authored
Merge pull request #1520 from martin-frbg/cpucounts
Catch invalid cpu count returned by CPU_COUNT_S
2 parents 2ca0faf + 7c86160 commit f29389c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

driver/others/memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ int ret;
212212
size = CPU_ALLOC_SIZE(nums);
213213
ret = sched_getaffinity(0,size,cpusetp);
214214
if (ret!=0) return nums;
215-
nums = CPU_COUNT_S(size,cpusetp);
215+
ret = CPU_COUNT_S(size,cpusetp);
216+
if (ret > 0 && ret < nums) nums = ret;
216217
CPU_FREE(cpusetp);
217218
return nums;
218219
#endif

0 commit comments

Comments
 (0)