]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
MdeModulePkg NvmExpressDxe: Refine BuildDevicePath API to follow spec
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / NvmExpressDxe / NvmExpressPassthru.c
index 02219219b66e29808529133d2569f59d63ecce17..ccff4f61d9ffc444bdeb87a36a962beca4e78aab 100644 (file)
@@ -3,7 +3,7 @@
   NVM Express specification.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -895,13 +895,17 @@ NvmExpressBuildDevicePath (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (NamespaceId == 0) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
   Status  = EFI_SUCCESS;\r
   Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This);\r
 \r
+  //\r
+  // Check NamespaceId is valid or not.\r
+  //\r
+  if ((NamespaceId == 0) ||\r
+    (NamespaceId > Private->ControllerData->Nn)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
   Node = (NVME_NAMESPACE_DEVICE_PATH *)AllocateZeroPool (sizeof (NVME_NAMESPACE_DEVICE_PATH));\r
   if (Node == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r