Skip to content

Commit 108a585

Browse files
Niklas Casselaxboe
authored andcommitted
nvme: do not call del_gendisk() on a disk that was never added
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: 33cfdc2 ("nvme: enforce extended LBA format for fabrics metadata") Signed-off-by: Niklas Cassel <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 22f614b commit 108a585

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/nvme/host/core.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
36693669
ns->disk = disk;
36703670

36713671
if (__nvme_revalidate_disk(disk, id))
3672-
goto out_free_disk;
3672+
goto out_put_disk;
36733673

36743674
if ((ctrl->quirks & NVME_QUIRK_LIGHTNVM) && id->vs[0] == 0x1) {
36753675
ret = nvme_nvm_register(ns, disk_name, node);
@@ -3696,8 +3696,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
36963696
/* prevent double queue cleanup */
36973697
ns->disk->queue = NULL;
36983698
put_disk(ns->disk);
3699-
out_free_disk:
3700-
del_gendisk(ns->disk);
37013699
out_unlink_ns:
37023700
mutex_lock(&ctrl->subsys->lock);
37033701
list_del_rcu(&ns->siblings);

0 commit comments

Comments
 (0)