pdr: pldm_entity_association_tree_find(): Early exit on bad arguments
Also identify the conditions in the doxygen commentary in the header.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I6a1dd656a9f888f147c4248b4793355f7ac8e7fc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6209ff6..ec6ab3f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -60,6 +60,7 @@
16. pdr: pldm_is_current_parent_child(): Return false for invalid arguments
17. pdr: pldm_entity_association_pdr_add(): Exit early on bad arguments
18. pdr: pldm_find_entity_ref_in_tree(): Exit early on bad arguments
+19. pdr: pldm_entity_association_tree_find(): Early exit on bad arguments
### Deprecated
diff --git a/include/libpldm/pdr.h b/include/libpldm/pdr.h
index a20bb70..e656ced 100644
--- a/include/libpldm/pdr.h
+++ b/include/libpldm/pdr.h
@@ -495,6 +495,9 @@
* @param[in/out] entity - entity type and instance id set on input, container
* id set on output
* @return pldm_entity_node* pointer to entity if found, NULL otherwise
+ *
+ * There are no entity nodes to search if tree is NULL, nor are there entity nodes to find if the
+ * search criteria are unspecified when entity is NULL.
*/
pldm_entity_node *
pldm_entity_association_tree_find(pldm_entity_association_tree *tree,
diff --git a/src/pdr.c b/src/pdr.c
index 3b30329..3ee8886 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -1189,6 +1189,9 @@
pldm_entity *entity)
{
assert(tree != NULL);
+ if (!tree || !entity) {
+ return NULL;
+ }
pldm_entity_node *node = NULL;
entity_association_tree_find(tree->root, entity, &node);