nvmf: fix crash on shutdown with invalid config
If a bdev-based controller is partially set up but then needs to be torn down due to an invalid configuration, the nvmf_bdev_ctrlr_detach() function could try to put a NULL spdk_io_channel. Add checks to avoid releasing resources that weren't allocated yet. Change-Id: I779c80f4dc654af3c4b0a49d8d216e13ab5f8333 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/373390 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
df36f4effd
commit
42ec0c007e
@ -675,9 +675,14 @@ nvmf_bdev_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem)
|
|||||||
|
|
||||||
for (i = 0; i < subsystem->dev.max_nsid; i++) {
|
for (i = 0; i < subsystem->dev.max_nsid; i++) {
|
||||||
if (subsystem->dev.ns_list[i]) {
|
if (subsystem->dev.ns_list[i]) {
|
||||||
spdk_put_io_channel(subsystem->dev.ch[i]);
|
if (subsystem->dev.ch[i]) {
|
||||||
spdk_bdev_close(subsystem->dev.desc[i]);
|
spdk_put_io_channel(subsystem->dev.ch[i]);
|
||||||
subsystem->dev.ch[i] = NULL;
|
subsystem->dev.ch[i] = NULL;
|
||||||
|
}
|
||||||
|
if (subsystem->dev.desc[i]) {
|
||||||
|
spdk_bdev_close(subsystem->dev.desc[i]);
|
||||||
|
subsystem->dev.desc[i] = NULL;
|
||||||
|
}
|
||||||
subsystem->dev.ns_list[i] = NULL;
|
subsystem->dev.ns_list[i] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user