diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index cc09b81fc7f4..8f3fbe5ca937 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2311,15 +2311,13 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct memset(subsys->subnqn + off, 0, sizeof(subsys->subnqn) - off); } -static void __nvme_release_subsystem(struct nvme_subsystem *subsys) -{ - ida_simple_remove(&nvme_subsystems_ida, subsys->instance); - kfree(subsys); -} - static void nvme_release_subsystem(struct device *dev) { - __nvme_release_subsystem(container_of(dev, struct nvme_subsystem, dev)); + struct nvme_subsystem *subsys = + container_of(dev, struct nvme_subsystem, dev); + + ida_simple_remove(&nvme_subsystems_ida, subsys->instance); + kfree(subsys); } static void nvme_destroy_subsystem(struct kref *ref) @@ -2477,7 +2475,7 @@ static int nvme_init_subsystem(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) mutex_lock(&nvme_subsystems_lock); found = __nvme_find_get_subsystem(subsys->subnqn); if (found) { - __nvme_release_subsystem(subsys); + put_device(&subsys->dev); subsys = found; if (!nvme_validate_cntlid(subsys, ctrl, id)) {