Skip to content

Commit

Permalink
nvme: fix controller instance leak
Browse files Browse the repository at this point in the history
If the driver has to unbind from the controller for an early failure
before the subsystem has been set up, there won't be a subsystem holding
the controller's instance, so the controller needs to free its own
instance in this case.

Fixes: 733e4b6 ("nvme: Assign subsys instance from first ctrl")
Signed-off-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
  • Loading branch information
Keith Busch authored and Sagi Grimberg committed Aug 28, 2020
1 parent 70e3798 commit 192f6c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4394,7 +4394,7 @@ static void nvme_free_ctrl(struct device *dev)
struct nvme_subsystem *subsys = ctrl->subsys;
struct nvme_cel *cel, *next;

if (subsys && ctrl->instance != subsys->instance)
if (!subsys || ctrl->instance != subsys->instance)
ida_simple_remove(&nvme_instance_ida, ctrl->instance);

list_for_each_entry_safe(cel, next, &ctrl->cels, entry) {
Expand Down

0 comments on commit 192f6c2

Please sign in to comment.