pdr: Add preconditions for pldm_entity_association_tree_copy_root()

pldm_entity_association_tree_copy_root() requires that the arguments
passed point to valid objects. Ensure this is documented, and add
assert()s for early warning of precondition violation in debug builds

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I15f4f10d5e7a8cebfffae94bb868a905c7c98f3d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 563ce8e..6954de0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,7 @@
 5. pdr: Stabilise pldm_pdr_find_last_in_range() API
 6. pdr: Stabilise pldm_entity_association_pdr_add_from_node_with_record_handle()
 7. oem: meta: stabilise decode_oem_meta_file_io_req()
+8. pdr: pldm_entity_association_tree_copy_root(): Document preconditions
 
 ### Fixed
 
diff --git a/include/libpldm/pdr.h b/include/libpldm/pdr.h
index b62b23b..5e42438 100644
--- a/include/libpldm/pdr.h
+++ b/include/libpldm/pdr.h
@@ -548,6 +548,9 @@
 
 /** @brief Create a copy of an existing entity association tree
  *
+ *  @pre org_tree must point to a valid object
+ *  @pre new_tree must point to a valid object
+ *
  *  @param[in] org_tree - pointer to source tree
  *  @param[in/out] new_tree - pointer to destination tree
  */
diff --git a/src/pdr.c b/src/pdr.c
index 8865002..ab35d2a 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -1216,6 +1216,9 @@
 	pldm_entity_association_tree *org_tree,
 	pldm_entity_association_tree *new_tree)
 {
+	assert(org_tree != NULL);
+	assert(new_tree != NULL);
+
 	new_tree->last_used_container_id = org_tree->last_used_container_id;
 	entity_association_tree_copy(org_tree->root, &(new_tree->root));
 }