cpu-set-util: check if cpu set is already allocated

Prompted by CID#1611789, CID#1611790, and CID#1611791.
This commit is contained in:
Yu Watanabe
2025-07-26 04:59:58 +09:00
parent 04a99c48d2
commit d54f1e4329
+3 -1
View File
@@ -133,8 +133,10 @@ int cpu_set_realloc(CPUSet *c, size_t n) {
return -ERANGE;
n = CPU_ALLOC_SIZE(n);
if (n <= c->allocated)
if (n <= c->allocated) {
assert(c->set || n == 0);
return 0;
}
if (!GREEDY_REALLOC0(c->set, DIV_ROUND_UP(n, sizeof(cpu_set_t))))
return -ENOMEM;