Return value of numa_node_of_cpu may be -1, it can't be used as numa map index.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- wd_sched.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/wd_sched.c b/wd_sched.c index 9a52c4d..cbd7a9b 100644 --- a/wd_sched.c +++ b/wd_sched.c @@ -177,6 +177,11 @@ static handle_t session_sched_init(handle_t h_sched_ctx, void *sched_param) int node = numa_node_of_cpu(cpu); struct sched_key *skey;
+ if (node < 0) { + WD_ERR("invalid: failed to get numa node!\n"); + return (handle_t)(-WD_EINVAL); + } + if (!sched_ctx) { WD_ERR("invalid: sched ctx is NULL!\n"); return (handle_t)(-WD_EINVAL);