cpu-set-util: fix null pointer dereference and several cleanups (#37900)
Fixes CID#1611618.
This commit is contained in:
@@ -3979,7 +3979,6 @@ static int compile_suggested_paths(const ExecContext *c, const ExecParameters *p
|
||||
}
|
||||
|
||||
static int exec_context_cpu_affinity_from_numa(const ExecContext *c, CPUSet *ret) {
|
||||
_cleanup_(cpu_set_reset) CPUSet s = {};
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
@@ -3987,16 +3986,17 @@ static int exec_context_cpu_affinity_from_numa(const ExecContext *c, CPUSet *ret
|
||||
|
||||
if (!c->numa_policy.nodes.set) {
|
||||
log_debug("Can't derive CPU affinity mask from NUMA mask because NUMA mask is not set, ignoring");
|
||||
*ret = (CPUSet) {};
|
||||
return 0;
|
||||
}
|
||||
|
||||
_cleanup_(cpu_set_done) CPUSet s = {};
|
||||
r = numa_to_cpu_set(&c->numa_policy, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
cpu_set_reset(ret);
|
||||
|
||||
return cpu_set_add_all(ret, &s);
|
||||
*ret = TAKE_STRUCT(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_shifted_fd(int *fds, size_t fds_size, size_t *n_fds, int *fd) {
|
||||
@@ -5107,7 +5107,7 @@ int exec_invoke(
|
||||
}
|
||||
|
||||
if (context->cpu_affinity_from_numa || context->cpu_set.set) {
|
||||
_cleanup_(cpu_set_reset) CPUSet converted_cpu_set = {};
|
||||
_cleanup_(cpu_set_done) CPUSet converted_cpu_set = {};
|
||||
const CPUSet *cpu_set;
|
||||
|
||||
if (context->cpu_affinity_from_numa) {
|
||||
|
||||
Reference in New Issue
Block a user