diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-08-19 11:18:42 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-09-06 15:31:23 +0800 |
commit | 284dc9bfe40dfb113986ed49d6419435d42f22b3 (patch) | |
tree | cf796854ebfcd5bf4335004710e3b542fb5c2a67 /MdeModulePkg | |
parent | 946f48ebe6222ce5a5d3650fc19691ae4e7ad8b2 (diff) | |
download | edk2-284dc9bfe40dfb113986ed49d6419435d42f22b3.zip edk2-284dc9bfe40dfb113986ed49d6419435d42f22b3.tar.gz edk2-284dc9bfe40dfb113986ed49d6419435d42f22b3.tar.bz2 |
MdeModulePkg NvmExpressDxe: Refine GetNameSpace API to follow spec
According to the UEFI spec,
EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() should return
EFI_NOT_FOUND when the input DevicePath is a device path node type that
the NVM Express Pass Thru driver supports, but there is not a valid
translation from DevicePath to a namespace ID. Current code will return
EFI_SUCCESS. This commit adds additional check in the GetNameSpace API to
make sure correct status is returned.
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.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c index ccff4f6..f0d2f5a 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c @@ -820,6 +820,7 @@ NvmExpressGetNamespace ( )
{
NVME_NAMESPACE_DEVICE_PATH *Node;
+ NVME_CONTROLLER_PRIVATE_DATA *Private;
if ((This == NULL) || (DevicePath == NULL) || (NamespaceId == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -829,13 +830,22 @@ NvmExpressGetNamespace ( return EFI_UNSUPPORTED;
}
- Node = (NVME_NAMESPACE_DEVICE_PATH *)DevicePath;
+ Node = (NVME_NAMESPACE_DEVICE_PATH *)DevicePath;
+ Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This);
if (DevicePath->SubType == MSG_NVME_NAMESPACE_DP) {
if (DevicePathNodeLength(DevicePath) != sizeof(NVME_NAMESPACE_DEVICE_PATH)) {
return EFI_NOT_FOUND;
}
+ //
+ // Check NamespaceId in the device path node is valid or not.
+ //
+ if ((Node->NamespaceId == 0) ||
+ (Node->NamespaceId > Private->ControllerData->Nn)) {
+ return EFI_NOT_FOUND;
+ }
+
*NamespaceId = Node->NamespaceId;
return EFI_SUCCESS;
|