Commit 42ec0c00 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/373390


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent df36f4ef
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -675,9 +675,14 @@ nvmf_bdev_ctrlr_detach(struct spdk_nvmf_subsystem *subsystem)

	for (i = 0; i < subsystem->dev.max_nsid; i++) {
		if (subsystem->dev.ns_list[i]) {
			if (subsystem->dev.ch[i]) {
				spdk_put_io_channel(subsystem->dev.ch[i]);
			spdk_bdev_close(subsystem->dev.desc[i]);
				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;
		}
	}