Revision: 19749
http://sourceforge.net/p/edk2/code/19749
Author: dandanbi
Date: 2016-01-26 09:42:58 +0000 (Tue, 26 Jan 2016)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Eric Dong <[email protected]>
Reviewed-by: Liming Gao <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
Modified: trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
2016-01-26 08:51:13 UTC (rev 19748)
+++ trunk/edk2/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
2016-01-26 09:42:58 UTC (rev 19749)
@@ -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 @@
@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 @@
//
// 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 @@
//
// This question is not in the requested string. Skip it.
//
- return EFI_SUCCESS;
+ return EFI_NOT_FOUND;
}
//
@@ -1772,8 +1773,21 @@
}
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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);
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits