nvme: Free ctrl device name on init failure
authorKeith Busch <keith.busch@intel.com>
Mon, 26 Nov 2018 23:39:47 +0000 (16:39 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 27 Nov 2018 07:35:15 +0000 (08:35 +0100)
Free the kobject name that was allocated for the controller device on
failure rather than its parent.

Fixes: d22524a4782a9 ("nvme: switch controller refcounting to use struct device")
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c

index 559d567693b8d060b920952e8429d219471b9569..5afda6fe5ae90aae5db53bde537e1411148110f6 100644 (file)
@@ -3585,7 +3585,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 
        return 0;
 out_free_name:
-       kfree_const(dev->kobj.name);
+       kfree_const(ctrl->device->kobj.name);
 out_release_instance:
        ida_simple_remove(&nvme_instance_ida, ctrl->instance);
 out: