From 80b405a64283b5adfd53b4f4fa48128c58422265 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Tue, 30 Aug 2016 16:34:09 +0800 Subject: [PATCH] MdeModulePkg NvmExpressDxe: Add NamespaceId validity check in PassThru According to the UEFI spec, EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.PassThru() should return EFI_INVALID_PARAMETER if the input 'NamespaceId' is invalid for the NVM Express controller. This commit adds check in PassThru() to follow this rule. Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Feng Tian --- MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c index 2209ee624b..96e9d88e52 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c @@ -422,6 +422,14 @@ NvmExpressPassThru ( Private = NVME_CONTROLLER_PRIVATE_DATA_FROM_PASS_THRU (This); + // + // Check NamespaceId is valid or not. + // + if ((NamespaceId > Private->ControllerData->Nn) && + (NamespaceId != (UINT32) -1)) { + return EFI_INVALID_PARAMETER; + } + // // Check whether TransferLength exceeds the maximum data transfer size. //