From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=15.233.44.27; helo=g2t2354.austin.hpe.com; envelope-from=cinnamon.shia@hpe.com; receiver=edk2-devel@lists.01.org Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4A850203BB548 for ; Fri, 11 May 2018 08:21:58 -0700 (PDT) Received: from ARBA3VIL42.asiapacific.hpqcorp.net (unknown [16.169.11.24]) by g2t2354.austin.hpe.com (Postfix) with ESMTP id F4020EE; Fri, 11 May 2018 15:21:54 +0000 (UTC) From: cinnamon shia To: edk2-devel@lists.01.org Cc: lersek@redhat.com, star.zeng@intel.com, cinnamon shia , Ansen Huang Date: Fri, 11 May 2018 23:21:12 +0800 Message-Id: <20180511152112.33156-2-cinnamon.shia@hpe.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20180511152112.33156-1-cinnamon.shia@hpe.com> References: <20180511152112.33156-1-cinnamon.shia@hpe.com> Subject: [PATCH v2 2/2] MdeModulePkg Variable: Fix the returned status in UpdateVariableStore X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 May 2018 15:21:58 -0000 If Fvb is a NULL, return EFI_UNSUPPORTED. If the remaining size is not enough, return EFI_OUT_OF_RESOURCES. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: cinnamon shia Signed-off-by: Ansen Huang --- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 7303681aaa..d17361f805 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -238,6 +238,8 @@ IsValidVariableHeader ( @param Buffer Pointer to the buffer from which data is written. @retval EFI_INVALID_PARAMETER Parameters not valid. + @retval EFI_UNSUPPORTED Fvb is a NULL for Non-Volatile variable update. + @retval EFI_OUT_OF_RESOURCES The remaining size is not enough. @retval EFI_SUCCESS Variable store successfully updated. **/ @@ -274,7 +276,7 @@ UpdateVariableStore ( // if (!Volatile) { if (Fvb == NULL) { - return EFI_INVALID_PARAMETER; + return EFI_UNSUPPORTED; } Status = Fvb->GetPhysicalAddress(Fvb, &FvVolHdr); ASSERT_EFI_ERROR (Status); @@ -289,7 +291,7 @@ UpdateVariableStore ( } if ((DataPtr + DataSize) > ((EFI_PHYSICAL_ADDRESS) (UINTN) ((UINT8 *) FwVolHeader + FwVolHeader->FvLength))) { - return EFI_INVALID_PARAMETER; + return EFI_OUT_OF_RESOURCES; } } else { // @@ -302,7 +304,7 @@ UpdateVariableStore ( } if ((DataPtr + DataSize) > ((UINTN) ((UINT8 *) VolatileBase + VolatileBase->Size))) { - return EFI_INVALID_PARAMETER; + return EFI_OUT_OF_RESOURCES; } // -- 2.16.1.windows.4