summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2016-08-19 11:08:04 +0800
committerHao Wu <hao.a.wu@intel.com>2016-09-06 15:31:20 +0800
commit946f48ebe6222ce5a5d3650fc19691ae4e7ad8b2 (patch)
treed4a81d93cda80face8b74ef5f1d0f08946dc836f /MdeModulePkg
parent6fe39780140f9f429c97a71ca3bfa4e16e779793 (diff)
downloadedk2-946f48ebe6222ce5a5d3650fc19691ae4e7ad8b2.tar.gz
edk2-946f48ebe6222ce5a5d3650fc19691ae4e7ad8b2.tar.bz2
edk2-946f48ebe6222ce5a5d3650fc19691ae4e7ad8b2.zip
MdeModulePkg NvmExpressDxe: Refine BuildDevicePath API to follow spec
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>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
index 02219219b6..ccff4f61d9 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
@@ -3,7 +3,7 @@
NVM Express specification.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -895,13 +895,17 @@ NvmExpressBuildDevicePath (
return EFI_INVALID_PARAMETER;
}
- if (NamespaceId == 0) {
- return EFI_NOT_FOUND;
- }
-
Status = EFI_SUCCESS;
Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This);
+ //
+ // Check NamespaceId is valid or not.
+ //
+ if ((NamespaceId == 0) ||
+ (NamespaceId > Private->ControllerData->Nn)) {
+ return EFI_NOT_FOUND;
+ }
+
Node = (NVME_NAMESPACE_DEVICE_PATH *)AllocateZeroPool (sizeof (NVME_NAMESPACE_DEVICE_PATH));
if (Node == NULL) {
return EFI_OUT_OF_RESOURCES;