Skip to contentSkip to conversation

blk-mq: NULL dereference in __blk_mq_alloc_rq_maps()

PATCH New Dan Carpenter 1 participant 1 message Sep 13, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: NULL dereference in __blk_mq_alloc_rq_maps()

We shouldn't set "set->tags" to NULL here because if we return -ENOMEM here then we call the function a second time. On the second time through the loop then the statement:

	set->tags[i] = blk_mq_init_rq_map(set, i);

will Oops. Also it is a memory leak and a layering violation. There is a correct call to kfree(set->tags) in blk_mq_alloc_tag_set().

Fixes a516440542af ('blk-mq: scale depth and rq map appropriate if low on memory')
block/blk-mq.c +0 -1
index 3d863df..7e7ca57 100644
@@ -1961,7 +1961,6 @@ out_unwind:
 	while (--i >= 0)
 		blk_mq_free_rq_map(set, set->tags[i], i);
 
-	set->tags = NULL;
 	return -ENOMEM;
 }