]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/commitdiff
Coverity fix
authorJustin Sobota <jsobota@ti.com>
Fri, 14 Nov 2014 20:56:41 +0000 (15:56 -0500)
committerJustin Sobota <jsobota@ti.com>
Fri, 14 Nov 2014 20:56:41 +0000 (15:56 -0500)
docs/ReleaseNotes_RM.doc
docs/ReleaseNotes_RM.pdf
rm.h
src/rm_allocator.c

index 2d4d370d4b6b3d9962cf666bc61a0860f1f259a7..c4b12f44580f18d17bb52345942e6c408d38560c 100644 (file)
Binary files a/docs/ReleaseNotes_RM.doc and b/docs/ReleaseNotes_RM.doc differ
index 444780917cc8896e7331f4716e072171d2727111..c7d725d2cbfc0250fb6304b7823ab1373077d3fd 100644 (file)
Binary files a/docs/ReleaseNotes_RM.pdf and b/docs/ReleaseNotes_RM.pdf differ
diff --git a/rm.h b/rm.h
index 988401f50d8a9a462b95044a5c9e1b42a5963b25..7ea7f81dedcb6e5c673b2f0ade9bb78a4ac3a03d 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -369,6 +369,9 @@ extern "C" {
 /** A resource name specified in the GRL, policy, and/or service request is greater than
  *  RM_NAME_MAX_CHARS */
 #define RM_ERROR_RESOURCE_NAME_TOO_LONG            RM_ERROR_BASE-52
+/** RM failed to create a new allocator - Occurred because an instance that does not use
+ *  allocators tried to create one (RM Client) */
+#define RM_ERROR_COULD_NOT_CREATE_NEW_ALLOCATOR    RM_ERROR_BASE-53
 
 /** 
  * @brief Maximum number of characters allowed for RM instance, resource, and
index ac351569d4e56b9ce37355cbc4e0f4ee73e6aef6..0ea83f96d031973aa1b0e75a3b7894e79780a29f 100644 (file)
@@ -98,7 +98,12 @@ static Rm_Allocator *allocatorAdd(Rm_Handle rmHandle, const char *resourceName)
             }
             else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
                 rmInst->u.cd.allocators = newAllocator;
-            }            
+            }
+            else {
+                /* Free allocator because instance type doesn't support allocators */
+                Rm_osalFree(newAllocator, sizeof(*newAllocator));
+                newAllocator = NULL;
+            }
         }
     }
     return (newAllocator);
@@ -1385,7 +1390,7 @@ static int32_t allocatorExtractGrlResProps(Rm_Handle rmHandle, const char *resou
             }
         }
     }
-    else {
+    else if (retVal != RM_ERROR_COULD_NOT_CREATE_NEW_ALLOCATOR) {
         rmAllocatorDelete(rmHandle, resourceName);
     }
 
@@ -1414,21 +1419,27 @@ int32_t rmAllocatorCreate(Rm_Handle rmHandle, const char *resourceName, Rm_Resou
     Rm_ResourceNode *treeNode = NULL;
 
     allocator = allocatorAdd(rmHandle, resourceName);
-    treeRoot = Rm_osalMalloc(sizeof(*treeRoot));
-    RB_INIT(treeRoot);
+    
+    if (allocator) {
+        treeRoot = Rm_osalMalloc(sizeof(*treeRoot));
+        RB_INIT(treeRoot);
 
-    while (range != NULL) {
-        treeNode = rmResourceNodeNew(range->base, range->length);
-        RB_INSERT(_Rm_AllocatorResourceTree, treeRoot, treeNode);
-        range = range->nextRange;
+        while (range != NULL) {
+            treeNode = rmResourceNodeNew(range->base, range->length);
+            RB_INSERT(_Rm_AllocatorResourceTree, treeRoot, treeNode);
+            range = range->nextRange;
+        }
+        if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+            rmResourceTreeWb(treeRoot);
+        }
+        
+        allocator->allocatorRootEntry = treeRoot;
+        RM_SS_OBJ_WB(allocator, Rm_Allocator);
+        return (RM_OK);
     }
-    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
-        rmResourceTreeWb(treeRoot);
+    else {
+        return (RM_ERROR_COULD_NOT_CREATE_NEW_ALLOCATOR);
     }
-    
-    allocator->allocatorRootEntry = treeRoot;
-    RM_SS_OBJ_WB(allocator, Rm_Allocator);
-    return(RM_OK);
 }
 
 /* FUNCTION PURPOSE: Returns a pointer to the allocator list