diff options
author | Keith Busch <kbusch@kernel.org> | 2020-08-26 20:53:04 +0300 |
---|---|---|
committer | Sagi Grimberg <sagi@grimberg.me> | 2020-08-29 02:43:57 +0300 |
commit | 192f6c29bb28bfd0a17e6ad331d09f1ec84143d0 (patch) | |
tree | f3e67ba8d3dbb4d0a60ea54bc6956165a90ed7cd /drivers/nvme/host | |
parent | 70e37988db94aba607d5491a94f80ba08e399b6b (diff) | |
download | linux-192f6c29bb28bfd0a17e6ad331d09f1ec84143d0.tar.xz |
nvme: fix controller instance leak
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: 733e4b69d508d ("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>
Diffstat (limited to 'drivers/nvme/host')
-rw-r--r-- | drivers/nvme/host/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e406c3cf55bc..d6186208abf9 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -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) { |