Commit 61e741ef authored by GangCao's avatar GangCao Committed by Jim Harris
Browse files

lib/nvme: add a check for valid namespace id



When the NVMe SSD supports multiple namespaces, we
allocate the related data structures to hold the
namespace related information. Add a check of valid
namespace id before accessing the memory structure.

Change-Id: I3176099a80f718d9470ee172a040a2ccc353aae9
Signed-off-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/427058


Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 2e2aba39
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -142,7 +142,16 @@ spdk_nvme_ns_get_id(struct spdk_nvme_ns *ns)
bool
spdk_nvme_ns_is_active(struct spdk_nvme_ns *ns)
{
	const struct spdk_nvme_ns_data *nsdata = _nvme_ns_get_data(ns);
	const struct spdk_nvme_ns_data *nsdata = NULL;

	/*
	 * According to the spec, valid NS has non-zero id.
	 */
	if (ns->id == 0) {
		return false;
	}

	nsdata = _nvme_ns_get_data(ns);

	/*
	 * According to the spec, Identify Namespace will return a zero-filled structure for