Skip to content

Commit ab3994f

Browse files
mcgrofChristoph Hellwig
authored andcommitted
nvme: add error handling support for add_disk()
We never checked for errors on add_disk() as this function returned void. Now that this is fixed, use the shiny new error handling. Signed-off-by: Luis Chamberlain <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 041bd1a commit ab3994f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3798,7 +3798,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
37983798

37993799
nvme_get_ctrl(ctrl);
38003800

3801-
device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups);
3801+
if (device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups))
3802+
goto out_cleanup_ns_from_list;
3803+
38023804
if (!nvme_ns_head_multipath(ns->head))
38033805
nvme_add_ns_cdev(ns);
38043806

@@ -3808,6 +3810,11 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
38083810

38093811
return;
38103812

3813+
out_cleanup_ns_from_list:
3814+
nvme_put_ctrl(ctrl);
3815+
down_write(&ctrl->namespaces_rwsem);
3816+
list_del_init(&ns->list);
3817+
up_write(&ctrl->namespaces_rwsem);
38113818
out_unlink_ns:
38123819
mutex_lock(&ctrl->subsys->lock);
38133820
list_del_rcu(&ns->siblings);

0 commit comments

Comments
 (0)