]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cpu-set-util: check if cpu set is already allocated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 25 Jul 2025 17:23:52 +0000 (02:23 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 25 Jul 2025 19:59:58 +0000 (04:59 +0900)
Prompted by CID#1611789, CID#1611790, and CID#1611791.

src/shared/cpu-set-util.c

index cef23889caf1c0148fe2e38272bb498c1ae4901b..222e4b7e1792f5efb97b82db432c1cdd09169806 100644 (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;