nvme: clear the request_queue pointers on failure in nvme_alloc_admin_tag_set
authorMaurizio Lombardi <mlombard@redhat.com>
Fri, 27 Jan 2023 15:42:37 +0000 (16:42 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 1 Feb 2023 13:18:46 +0000 (14:18 +0100)
commitfd62678ab55cb01e11a404d302cdade222bf4022
treec20351bc08526ced74526ad304c4b54546e70bad
parent0cab4404874f2de52617de8400c844891c6ea1ce
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 <mlombard@redhat.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c