]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg NvmExpressDxe: Refine BuildDevicePath API to follow spec
authorHao Wu <hao.a.wu@intel.com>
Fri, 19 Aug 2016 03:08:04 +0000 (11:08 +0800)
committerHao Wu <hao.a.wu@intel.com>
Tue, 6 Sep 2016 07:31:20 +0000 (15:31 +0800)
According to the UEFI spec,
EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() should return
EFI_NOT_FOUND when the input NamespaceId is not valid. However, current
code returns EFI_DEVICE_ERROR instead. This commit modifies the check for
input NamespaceId to return the correct status.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
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