diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 5f13f4d0bcce..527d315dc1a5 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -88,10 +88,11 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues) unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set) { unsigned int *map; + size_t sz; /* If cpus are offline, map them to first hctx */ - map = kzalloc_node(sizeof(*map) * nr_cpu_ids, GFP_KERNEL, - set->numa_node); + sz = max_t(unsigned int, nr_cpu_ids, num_possible_cpus()); + map = kzalloc_node(sizeof(*map) * sz, GFP_KERNEL, set->numa_node); if (!map) return NULL;