Skip to contentSkip to conversation

blk-mq: zero out ctx_map during initialization

PATCH In review Jeff Moyer 2 participants 2 messages Oct 21, 2013 Block layer

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 blk-mq: zero out ctx_map during initialization

Hi,

ctx_map may contain random garbage, leading to (potentially chronic but harmless) false positives in blk_mq_hctx_has_pending.

Note: I have not observed this in practice, just by code inspection.

block/blk-mq.c +1 -1
index 923e9e1..e9be5ed 100644
@@ -1197,7 +1197,7 @@ static int blk_mq_init_hw_queues(struct request_queue *q,
 			break;
 
 		num_maps = ALIGN(nr_cpu_ids, BITS_PER_LONG) / BITS_PER_LONG;
-		hctx->ctx_map = kmalloc_node(num_maps * sizeof(unsigned long),
+		hctx->ctx_map = kzalloc_node(num_maps * sizeof(unsigned long),
 						GFP_KERNEL, node);
 		if (!hctx->ctx_map)
 			break;
maintainer
#1 lore raw
Quoted 6 lines · Jeff Moyer

Hi,

ctx_map may contain random garbage, leading to (potentially chronic but harmless) false positives in blk_mq_hctx_has_pending.

Note: I have not observed this in practice, just by code inspection.

It's the prudent thing to do in any case. Applied.

Signature · 1 line
Jens Axboe