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

@@ -22,7 +22,9 @@
@param [in] Node Newly created node.
@param [in] ParentNode If provided, set ParentNode as the parent
of the node created.
@param [out] NewObjectNode If success, contains the created object node.
@param [out] NewObjectNode If not NULL:
- and Success, contains the created Node.
- and Error, reset to NULL.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_INVALID_PARAMETER Invalid parameter.
@@ -39,7 +41,7 @@ LinkNode (
EFI_STATUS Status;
if (NewObjectNode != NULL) {
*NewObjectNode = Node;
*NewObjectNode = NULL;
}
// Add RdNode as the last element.
@@ -51,6 +53,10 @@ LinkNode (
}
}
if (NewObjectNode != NULL) {
*NewObjectNode = Node;
}
return EFI_SUCCESS;
}