From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0633F1A1E74 for ; Sun, 28 Aug 2016 19:42:44 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 28 Aug 2016 19:42:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,594,1464678000"; d="scan'208";a="1021563573" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.34]) by orsmga001.jf.intel.com with ESMTP; 28 Aug 2016 19:42:43 -0700 From: Hao Wu To: edk2-devel@lists.01.org, feng.tian@intel.com Cc: Hao Wu Date: Mon, 29 Aug 2016 10:42:22 +0800 Message-Id: <1472438547-9368-3-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1472438547-9368-1-git-send-email-hao.a.wu@intel.com> References: <1472438547-9368-1-git-send-email-hao.a.wu@intel.com> Subject: [PATCH 2/7] MdeModulePkg NvmExpressDxe: Refine BuildDevicePath API to follow spec X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2016 02:42:44 -0000 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 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu --- MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c index 0221921..ccff4f6 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.
- Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
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; -- 1.9.5.msysgit.0