MGS-2715 [#imx-418] fix 6.2.0.p2 Coverity high impact issues
authorXianzhong <xianzhong.li@nxp.com>
Mon, 6 Mar 2017 08:47:55 +0000 (16:47 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:10:51 +0000 (15:10 -0500)
fix coverity high impact issues in 6.2.0.p2 gpu kernel driver

59982:  Resource leak (mappedQueue)
57724: Pointer to local outside scope (_nextCMDBUF)
57722: Uninitialized scalar variable (linkBytes)
57721: Uninitialized scalar variable (nopBytes)

Date: Mar 06, 2017
Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command.c
drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command_vg.c

index e004276..2a56dbc 100644 (file)
@@ -880,6 +880,7 @@ _ProcessUserCommandBufferList(
     gceSTATUS           status;
     gctBOOL             needCopy;
 
+    struct _gcoCMDBUF   _nextCMDBUF;
     struct _gcoCMDBUF   _commandBufferObject;
     gcoCMDBUF           currentCMDBUF;
     gcoCMDBUF           currentCMDBUFUser = CommandBufferListHead;
@@ -901,10 +902,9 @@ _ProcessUserCommandBufferList(
     {
         gcoCMDBUF           nextCMDBUFUser;
         gcoCMDBUF           nextCMDBUF;
-        struct _gcoCMDBUF   _nextCMDBUF;
         gctUINT8_PTR        fenceLogical = gcvNULL;
         gctUINT8_PTR        linkLogical;
-        gctUINT32           linkBytes;
+        gctUINT32           linkBytes = 8;
         gctUINT32           linkLow;
         gctUINT32           linkHigh;
 
@@ -947,7 +947,7 @@ _ProcessUserCommandBufferList(
             /* Fill NOPs in space reserved for fence. */
             while (i--)
             {
-                gctSIZE_T nopBytes;
+                gctSIZE_T nopBytes = 8;
                 gcmkONERROR(gckHARDWARE_Nop(Command->kernel->hardware, fenceLogical, &nopBytes));
                 fenceLogical += nopBytes;
             }
index 60a0670..2c72ec0 100644 (file)
@@ -3565,7 +3565,7 @@ gckVGCOMMAND_Commit(
     do
     {
         gctBOOL haveFETasks;
-        gctUINT queueSize;
+        gctUINT queueSize = 0;
         gcsVGCMDQUEUE_PTR mappedQueue=gcvNULL;
         gcsVGCMDQUEUE_PTR userEntry=gcvNULL;
         gcsKERNEL_CMDQUEUE_PTR kernelEntry;
@@ -3887,8 +3887,11 @@ gckVGCOMMAND_Commit(
                             Command, currentLength
                             ));
             }
+        }
+        while (gcvFALSE);
 
-
+        if (mappedQueue)
+        {
             if(!needCopy)
             {
                 /* Unmap the user command buffer. */
@@ -3904,7 +3907,6 @@ gckVGCOMMAND_Commit(
                 gcmkERR_BREAK(gckOS_Free(Command->os, mappedQueue));
             }
         }
-        while (gcvFALSE);
 
         /* Release the mutex. */
         gcmkCHECK_STATUS(gckOS_ReleaseMutex(