]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blobdiff - packages/ti/sdo/ipc/ListMP.c
ipc: static analysis issues on NULL pointer access
[ipc/ipcdev.git] / packages / ti / sdo / ipc / ListMP.c
index 6b797e471e652af45594f80dc8699855faf38c95..659757b52bfe28aa1deb279f561480f813e24857 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012-2015 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2012-2018 Texas Instruments Incorporated - http://www.ti.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -181,6 +181,10 @@ Int ListMP_open(String name, ListMP_Handle *handlePtr)
     }
 
     sharedAddr = SharedRegion_getPtr(sharedShmBase);
+    if ( sharedAddr == NULL ) {
+        *handlePtr = NULL;
+        return (ListMP_E_NOTFOUND);
+    }
 
     status = ListMP_openByAddr(sharedAddr, handlePtr);
 
@@ -856,15 +860,18 @@ Int ti_sdo_ipc_ListMP_Instance_init(ti_sdo_ipc_ListMP_Object *obj,
         obj->cacheLineSize = SharedRegion_getCacheLineSize(obj->regionId);
 
 #ifdef xdc_target__isaCompatible_v7A
-    /* ARM speculative execution might have pulled attrs into cache */
-    if (obj->cacheEnabled) {
-        Cache_inv(obj->attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL,
+        /* ARM speculative execution might have pulled attrs into cache */
+        if (obj->cacheEnabled) {
+            Cache_inv(obj->attrs, sizeof(ti_sdo_ipc_ListMP_Attrs), Cache_Type_ALL,
                 TRUE);
-    }
+        }
 #endif
         /* get the local address of the SRPtr */
         localAddr = SharedRegion_getPtr(obj->attrs->gateMPAddr);
 
+        /* Do NULL check on localAddr */
+        Assert_isTrue(localAddr != NULL, ti_sdo_ipc_Ipc_A_internal);
+
         status = GateMP_openByAddr(localAddr, (GateMP_Handle *)&(obj->gate));
         if (status != GateMP_S_SUCCESS) {
             Error_raise(eb, ti_sdo_ipc_Ipc_E_internal, 0, 0);