Skip to content

Commit fd62678

Browse files
maurizio-lombardiChristoph Hellwig
authored andcommitted
nvme: clear the request_queue pointers on failure in nvme_alloc_admin_tag_set
If nvme_alloc_admin_tag_set() fails, the admin_q and fabrics_q pointers are left with an invalid, non-NULL value. Other functions may then check the pointers and dereference them, e.g. in nvme_probe() -> out_disable: -> nvme_dev_remove_admin(). Fix the bug by setting admin_q and fabrics_q to NULL in case of error. Also use the set variable to free the tag_set as ctrl->admin_tagset isn't initialized yet. Signed-off-by: Maurizio Lombardi <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 0cab440 commit fd62678

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4892,7 +4892,9 @@ int nvme_alloc_admin_tag_set(struct nvme_ctrl *ctrl, struct blk_mq_tag_set *set,
48924892
blk_mq_destroy_queue(ctrl->admin_q);
48934893
blk_put_queue(ctrl->admin_q);
48944894
out_free_tagset:
4895-
blk_mq_free_tag_set(ctrl->admin_tagset);
4895+
blk_mq_free_tag_set(set);
4896+
ctrl->admin_q = NULL;
4897+
ctrl->fabrics_q = NULL;
48964898
return ret;
48974899
}
48984900
EXPORT_SYMBOL_GPL(nvme_alloc_admin_tag_set);

0 commit comments

Comments
 (0)