)\r
{\r
NVME_NAMESPACE_DEVICE_PATH *Node;\r
+ NVME_CONTROLLER_PRIVATE_DATA *Private;\r
\r
if ((This == NULL) || (DevicePath == NULL) || (NamespaceId == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
return EFI_UNSUPPORTED;\r
}\r
\r
- Node = (NVME_NAMESPACE_DEVICE_PATH *)DevicePath;\r
+ Node = (NVME_NAMESPACE_DEVICE_PATH *)DevicePath;\r
+ Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This);\r
\r
if (DevicePath->SubType == MSG_NVME_NAMESPACE_DP) {\r
if (DevicePathNodeLength(DevicePath) != sizeof(NVME_NAMESPACE_DEVICE_PATH)) {\r
return EFI_NOT_FOUND;\r
}\r
\r
+ //\r
+ // Check NamespaceId in the device path node is valid or not.\r
+ //\r
+ if ((Node->NamespaceId == 0) ||\r
+ (Node->NamespaceId > Private->ControllerData->Nn)) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+\r
*NamespaceId = Node->NamespaceId;\r
\r
return EFI_SUCCESS;\r