diff options
author | Sam Nelson <sam.nelson@ti.com> | 2019-10-07 21:09:34 -0400 |
---|---|---|
committer | Sam Nelson <sam.nelson@ti.com> | 2019-10-08 15:51:06 -0400 |
commit | 85e520ec41b524260c47a46f3db0de1de728ae8c (patch) | |
tree | c38390fc7c6642c03ffa30c10dd479ceaca5103d | |
parent | 192facbd050ce886027dda5d3a85203b8139884c (diff) | |
download | ipc-85e520ec41b524260c47a46f3db0de1de728ae8c.tar.gz |
ListMP: Add additional check to handle no Assert case
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
-rw-r--r-- | packages/ti/sdo/ipc/ListMP.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/packages/ti/sdo/ipc/ListMP.c b/packages/ti/sdo/ipc/ListMP.c index 2f04afb..b31ea17 100644 --- a/packages/ti/sdo/ipc/ListMP.c +++ b/packages/ti/sdo/ipc/ListMP.c @@ -356,6 +356,11 @@ Ptr ListMP_getHead(ListMP_Handle handle) /* Assert that pointer is not NULL */ Assert_isTrue(localHeadNext != NULL, ti_sdo_ipc_Ipc_A_nullPointer); + /* Additional check to handle case when Assert is disabled */ + if (localHeadNext == NULL) { + elem = NULL; + goto leave; + } /* See if the ListMP was empty */ if (localHeadNext == (ListMP_Elem *)(&(attrs->head))) { @@ -377,6 +382,11 @@ Ptr ListMP_getHead(ListMP_Handle handle) /* Assert that pointer is not NULL */ Assert_isTrue(localNext != NULL, ti_sdo_ipc_Ipc_A_nullPointer); + /* Additional check to handle case when Assert is disabled */ + if (localNext == NULL) { + elem = NULL; + goto leave; + } /* Elem to return */ elem = localHeadNext; @@ -402,6 +412,8 @@ Ptr ListMP_getHead(ListMP_Handle handle) else ListMP_barrier(); +leave: + GateMP_leave((GateMP_Handle)obj->gate, key); return (elem); @@ -439,6 +451,11 @@ Ptr ListMP_getTail(ListMP_Handle handle) /* Assert that pointer is not NULL */ Assert_isTrue(localHeadPrev != NULL, ti_sdo_ipc_Ipc_A_nullPointer); + /* Additional check to handle case when Assert is disabled */ + if (localHeadPrev == NULL) { + elem = NULL; + goto leave; + } /* See if the ListMP was empty */ if (localHeadPrev == (ListMP_Elem *)(&(attrs->head))) { @@ -460,6 +477,11 @@ Ptr ListMP_getTail(ListMP_Handle handle) /* Assert that pointer is not NULL */ Assert_isTrue(localPrev != NULL, ti_sdo_ipc_Ipc_A_nullPointer); + /* Additional check to handle case when Assert is disabled */ + if (localPrev == NULL) { + elem = NULL; + goto leave; + } /* Elem to return */ elem = localHeadPrev; @@ -485,6 +507,7 @@ Ptr ListMP_getTail(ListMP_Handle handle) else ListMP_barrier(); +leave: GateMP_leave((GateMP_Handle)obj->gate, key); return (elem); @@ -830,8 +853,6 @@ Int ListMP_remove(ListMP_Handle handle, ListMP_Elem *elem) return ListMP_E_FAIL; } - - localPrevElemIsCached = SharedRegion_isCacheEnabled( SharedRegion_getId(localPrevElem)); localNextElemIsCached = SharedRegion_isCacheEnabled( |