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: GangCao <gang.cao@intel.com> Reviewed-on: https://review.gerrithub.io/427058 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
2e2aba3927
commit
61e741efca
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user