summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2016-01-26 09:42:58 +0000
committerdandanbi <dandanbi@Edk2>2016-01-26 09:42:58 +0000
commitf447734e4f9879e7333a3b6c5548f0d23529a3af (patch)
tree1a78a72e7ba197ebf592cb35c2047abc21db7d50
parent03805fc376239ddc56838d33b20a031734e3e3a1 (diff)
downloadedk2-f447734e4f9879e7333a3b6c5548f0d23529a3af.tar.gz
edk2-f447734e4f9879e7333a3b6c5548f0d23529a3af.tar.xz
edk2-f447734e4f9879e7333a3b6c5548f0d23529a3af.zip
MdeModulePkg:Make the logic in ConfigRouting.c clear and safe
The BlockData is expected to be NULL when to call function IsThisOpcodeRequired in each opcode,but now exists case that the Blockdata not be cleaned,then will be used in other opcode.it is not correct,now add the check before use. The comments and logic in function IsThisOpcodeRequired are not consistent,now refine the code to make the logic clear. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19749 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c143
1 files changed, 127 insertions, 16 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 8f0b96847d..3a871cf3ba 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -1,7 +1,7 @@
/** @file
Implementation of interfaces function for EFI_HII_CONFIG_ROUTING_PROTOCOL.
-Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 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
@@ -1466,7 +1466,8 @@ Done:
@param ReturnData The data block added for this opcode.
@retval EFI_SUCCESS This opcode is required.
- @retval Others This opcode is not required or error occur.
+ @retval EFI_NOT_FOUND This opcode is not required.
+ @retval Others Contain some error.
**/
EFI_STATUS
@@ -1498,7 +1499,7 @@ IsThisOpcodeRequired (
//
// This question is not in the requested string. Skip it.
//
- return EFI_SUCCESS;
+ return EFI_NOT_FOUND;
}
} else {
VarOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
@@ -1510,7 +1511,7 @@ IsThisOpcodeRequired (
//
// This question is not in the requested string. Skip it.
//
- return EFI_SUCCESS;
+ return EFI_NOT_FOUND;
}
//
@@ -1772,8 +1773,21 @@ ParseIfrData (
}
VarWidth = (UINT16) (sizeof (EFI_HII_REF));
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
break;
@@ -1800,17 +1814,28 @@ ParseIfrData (
}
VarWidth = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
- if (BlockData == NULL) {
- //
- // BlockData == NULL means this opcode is not in the requst array.
- //
- break;
- }
+ //
+ //when go to there,BlockData can't be NULLL.
+ //
+ ASSERT (BlockData != NULL);
if (IfrOpHdr->OpCode == EFI_IFR_ONE_OF_OP) {
//
@@ -1877,8 +1902,22 @@ ParseIfrData (
break;
}
VarWidth = IfrOrderedList->MaxContainers;
+
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
break;
@@ -1908,17 +1947,29 @@ ParseIfrData (
break;
}
VarWidth = (UINT16) sizeof (BOOLEAN);
+
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
- if (BlockData == NULL) {
- //
- // BlockData == NULL means this opcode is not in the requst array.
- //
- break;
- }
+ //
+ //when go to there,BlockData can't be NULLL.
+ //
+ ASSERT (BlockData != NULL);
//
// Add default value for standard ID by CheckBox Flag
@@ -1995,9 +2046,22 @@ ParseIfrData (
break;
}
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
VarWidth = (UINT16) sizeof (EFI_HII_DATE);
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
break;
@@ -2024,9 +2088,22 @@ ParseIfrData (
break;
}
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
VarWidth = (UINT16) sizeof (EFI_HII_TIME);
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
break;
@@ -2053,9 +2130,22 @@ ParseIfrData (
break;
}
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
VarWidth = (UINT16) (IfrString->MaxSize * sizeof (UINT16));
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
break;
@@ -2082,9 +2172,22 @@ ParseIfrData (
break;
}
+ //
+ // The BlockData may allocate by other opcode,need to clean.
+ //
+ if (BlockData != NULL){
+ BlockData = NULL;
+ }
+
VarWidth = (UINT16) (IfrPassword->MaxSize * sizeof (UINT16));
Status = IsThisOpcodeRequired(RequestBlockArray, HiiHandle, VarStorageData, IfrOpHdr, VarWidth, &BlockData);
if (EFI_ERROR (Status)) {
+ if (Status == EFI_NOT_FOUND){
+ //
+ //The opcode is not required,exit and parse other opcode.
+ //
+ break;
+ }
goto Done;
}
@@ -2288,6 +2391,14 @@ ParseIfrData (
PackageOffset += IfrOpHdr->Length;
}
+ //
+ //if Status == EFI_NOT_FOUND, just means the opcode is not required,not contain any error,
+ //so set the Status to EFI_SUCCESS.
+ //
+ if (Status == EFI_NOT_FOUND){
+ Status = EFI_SUCCESS;
+ }
+
Done:
for (LinkData = VarStorageData->BlockEntry.ForwardLink; LinkData != &VarStorageData->BlockEntry; LinkData = LinkData->ForwardLink) {
BlockData = BASE_CR (LinkData, IFR_BLOCK_DATA, Entry);