pdr: pldm_pdr_init(): Return NULL on allocation failure
Previously initialisation of the structure was protected from a failed
allocation using assert(). Instead, do what the API specification allows
us to do and perform an early exit by returning NULL.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: If6510014d383d815d42f48a2b607b12015e20bb2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6cdaa84..d249a68 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@
3. bios_table: pldm_bios_table_string_entry_encode_check(): Handle overflow
4. bios_table: pldm_bios_table_iter_create(): Return NULL on failed alloc
5. bios_table: pldm_bios_table_iter_next(): Invalid entry halts iteration
+6. pdr: pldm_pdr_init(): Return NULL on allocation failure
### Deprecated
diff --git a/src/pdr.c b/src/pdr.c
index 657612d..763fa72 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -117,7 +117,9 @@
pldm_pdr *pldm_pdr_init(void)
{
pldm_pdr *repo = malloc(sizeof(pldm_pdr));
- assert(repo != NULL);
+ if (!repo) {
+ return NULL;
+ }
repo->record_count = 0;
repo->size = 0;
repo->first = NULL;