mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
nvmet: propagate percpu_ref_init() failure in nvmet_ns_enable()
The return value of percpu_ref_init() is discarded. At this point ret is
0 from the preceding successful steps, so when the allocation inside
percpu_ref_init() fails the code jumps to the out_pr_exit cleanup chain
which ends with "return ret", i.e. reports success. The configfs enable
store then tells userspace the namespace was enabled even though it was
not and its backing device has already been torn down.
Capture the return value so the failure is propagated.
Fixes: 4082326807 ("nvmet: Fix crash when a namespace is disabled")
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
79aba4c940
commit
751709592d
|
|
@ -610,7 +610,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
|
|||
goto out_dev_put;
|
||||
}
|
||||
|
||||
if (percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL))
|
||||
ret = percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL);
|
||||
if (ret)
|
||||
goto out_pr_exit;
|
||||
|
||||
nvmet_ns_changed(subsys, ns->nsid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user