DynamicTablesPkg: Clear pointer in node creation fcts

The following functions:
- AmlCreateRootNode()
- AmlCreateObjectNode()
- AmlCreateDataNode()
create a node and return it by populating a pointer. This pointer
should only be considered/used if the function returns successfully.
Otherwise, the value stored in this pointer should be ignored.

For their error handling, some other functions assume that this
pointer is reset to NULL if an error occurs during a node creation.
To make this assumption correct, explicitly clear this input pointer.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
This commit is contained in:
Pierre Gondois
2021-10-08 15:46:18 +01:00
committed by mergify[bot]
parent 7b2022d39e
commit 2dd7dd3952
4 changed files with 40 additions and 10 deletions

View File

@ -33,7 +33,9 @@
RdNode is then added at the end of the variable
list of resource data elements, but before the
"End Tag" Resource Data.
@param [out] NewRdNode If not NULL, update the its value to RdNode.
@param [out] NewRdNode If not NULL:
- and Success, contains RdNode.
- and Error, reset to NULL.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@ -52,7 +54,7 @@ LinkRdNode (
AML_OBJECT_NODE *BufferOpNode;
if (NewRdNode != NULL) {
*NewRdNode = RdNode;
*NewRdNode = NULL;
}
if (ParentNode != NULL) {
@ -85,6 +87,10 @@ LinkRdNode (
}
}
if (NewRdNode != NULL) {
*NewRdNode = RdNode;
}
return Status;
error_handler: