Skip to contentSkip to conversation

dm: check for kmalloc failure in dm_init_request_based_blk_mq_queue()

PATCH In review Dan Carpenter 3 participants 3 messages Feb 9, 2016

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

PATCH 1/1 dm: check for kmalloc failure in dm_init_request_based_blk_mq_queue()

We can just return -ENOMEM if the kzalloc() fails.

Fixes 41b2facaf4ba ('dm: allocate blk_mq_tag_set rather than embed in mapped_device')
drivers/md/dm.c +2 -0
index 6b7e80e..1a5f879 100644
@@ -2736,6 +2736,8 @@ static int dm_init_request_based_blk_mq_queue(struct mapped_device *md,
 	int err;
 
 	md->tag_set = kzalloc(sizeof(struct blk_mq_tag_set), GFP_KERNEL);
+	if (!md->tag_set)
+		return -ENOMEM;
 	md->tag_set->ops = &dm_mq_ops;
 	md->tag_set->queue_depth = dm_get_blk_mq_queue_depth();
 	md->tag_set->numa_node = NUMA_NO_NODE;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Dan Carpenter

We can just return -ENOMEM if the kzalloc() fails.

Fixes 41b2facaf4ba ('dm: allocate blk_mq_tag_set rather than embed in mapped_device')
drivers/md/dm.c +2 -1
index 6b7e80e..1a5f879 100644
@@ -2736,6 +2736,8 @@ static int dm_init_request_based_blk_mq_queue(struct mapped_device *md,
 	int err;
 
 	md->tag_set = kzalloc(sizeof(struct blk_mq_tag_set), GFP_KERNEL);
+	if (!md->tag_set)
+		return -ENOMEM;
 	md->tag_set->ops = &dm_mq_ops;
 	md->tag_set->queue_depth = dm_get_blk_mq_queue_depth();
 	md->tag_set->numa_node = NUMA_NO_NODE;
 
--
Quoted 3 lines

dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Good catch,

Signature · 10 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html