]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nvme: do not call del_gendisk() on a disk that was never added
authorNiklas Cassel <niklas.cassel@wdc.com>
Sun, 7 Jun 2020 11:45:20 +0000 (13:45 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 11 Jun 2020 15:10:05 +0000 (09:10 -0600)
device_add_disk() is negated by del_gendisk().
alloc_disk_node() is negated by put_disk().

In nvme_alloc_ns(), device_add_disk() is one of the last things being
called in the success case, and only void functions are being called
after this. Therefore this call should not be negated in the error path.

The superfluous call to del_gendisk() leads to the following prints:
[    7.839975] kobject: '(null)' (000000001ff73734): is not initialized, yet kobject_put() is being called.
[    7.840865] WARNING: CPU: 2 PID: 361 at lib/kobject.c:736 kobject_put+0x70/0x120

Fixes: 2d87d89380e3 ("nvme: enforce extended LBA format for fabrics metadata")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/nvme/host/core.c

index 0585efa47d8fd8842a6675229dbaef976e1412ad..c2c5bc4fb702d37590f55a933baac8ffde49aebc 100644 (file)
@@ -3669,7 +3669,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        ns->disk = disk;
 
        if (__nvme_revalidate_disk(disk, id))
-               goto out_free_disk;
+               goto out_put_disk;
 
        if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) {
                ret = nvme_nvm_register(ns, disk_name, node);
@@ -3696,8 +3696,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        /* prevent double queue cleanup */
        ns->disk->queue = NULL;
        put_disk(ns->disk);
- out_free_disk:
-       del_gendisk(ns->disk);
  out_unlink_ns:
        mutex_lock(&ctrl->subsys->lock);
        list_del_rcu(&ns->siblings);