diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index 824db6f6ba23..545789386d52 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -406,6 +406,8 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx, int cpu = p->sq_thread_cpu; ret = -EINVAL; + if (cpu >= nr_cpu_ids || !cpu_online(cpu)) + goto err_sqpoll; cpuset_cpus_allowed(current, &allowed_mask); if (!cpumask_test_cpu(cpu, &allowed_mask)) goto err_sqpoll;