From: Yu Watanabe Date: Fri, 25 Jul 2025 17:23:52 +0000 (+0900) Subject: cpu-set-util: check if cpu set is already allocated X-Git-Tag: v258-rc2~81^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d54f1e4329aa2b80107383f99253f5f3df9f1f84;p=thirdparty%2Fsystemd.git cpu-set-util: check if cpu set is already allocated Prompted by CID#1611789, CID#1611790, and CID#1611791. --- diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c index cef23889caf..222e4b7e179 100644 --- a/src/shared/cpu-set-util.c +++ b/src/shared/cpu-set-util.c @@ -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;