pdr: pldm_entity_association_tree_init(): Return NULL on failed alloc
The API is documented as returning NULL on error, so exploit that
constraint on the caller to actually implement that behaviour.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Iaee36079909bc4e2e59c6a1df50120c9be68cd0e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 383aa2e..ab59e59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,7 @@
9. pdr: pldm_entity_node_get_remote_container_id() is a trivial accessor
10. pdr: pldm_pdr_fru_record_set_find_by_rsi(): Exit early on NULL arguments
+11. pdr: pldm_entity_association_tree_init(): Return NULL on failed alloc
### Deprecated
diff --git a/src/pdr.c b/src/pdr.c
index a58a2cc..be8b2fe 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -489,7 +489,9 @@
{
pldm_entity_association_tree *tree =
malloc(sizeof(pldm_entity_association_tree));
- assert(tree != NULL);
+ if (!tree) {
+ return NULL;
+ }
tree->root = NULL;
tree->last_used_container_id = 0;