edma3: PRSDK-3579: Clean up static analysis error in UART/SPI LLD caused by edma3 LLD
authorHao Zhang <hzhang@ti.com>
Fri, 23 Feb 2018 14:22:12 +0000 (09:22 -0500)
committerHao Zhang <hzhang@ti.com>
Fri, 23 Feb 2018 14:22:12 +0000 (09:22 -0500)
dmaChannelHwEvtMap is an array of size 2, lCh should be checked before
referencing drvObject->gblCfgParams.dmaChannelHwEvtMap[]

Signed-off-by: Hao Zhang <hzhang@ti.com>
packages/ti/sdo/edma3/drv/src/edma3_drv_basic.c

index 2a6ab6e155c0a32f2f4645c8272e49596810e663..107097364398e08baf97525b0e22c35fcac05d4d 100755 (executable)
@@ -1899,6 +1899,8 @@ EDMA3_DRV_Result EDMA3_DRV_enableTransfer (EDMA3_DRV_Handle hEdma,
         result = EDMA3_DRV_E_INVALID_PARAM;
         }
 
+  if (lCh < EDMA3_MAX_DMA_CH)
+  {
        /* Trigger type is Event */
     if ((EDMA3_DRV_TRIG_MODE_EVENT == trigMode)
        && ((drvObject->gblCfgParams.dmaChannelHwEvtMap [lCh/32U]
@@ -1907,6 +1909,7 @@ EDMA3_DRV_Result EDMA3_DRV_enableTransfer (EDMA3_DRV_Handle hEdma,
         /* Channel was not mapped to any Hw Event. */
         result = EDMA3_DRV_E_INVALID_PARAM;
         }
+  }
 #endif
         }
                
@@ -2049,6 +2052,8 @@ EDMA3_DRV_Result EDMA3_DRV_disableTransfer (EDMA3_DRV_Handle hEdma,
         result = EDMA3_DRV_E_INVALID_PARAM;
         }
 
+  if (lCh < EDMA3_MAX_DMA_CH)
+  {
        /* Trigger type is Event */
     if ((EDMA3_DRV_TRIG_MODE_EVENT == trigMode)
        && ((drvObject->gblCfgParams.dmaChannelHwEvtMap [lCh/32U]
@@ -2057,6 +2062,7 @@ EDMA3_DRV_Result EDMA3_DRV_disableTransfer (EDMA3_DRV_Handle hEdma,
         /* Channel was not mapped to any Hw Event. */
         result = EDMA3_DRV_E_INVALID_PARAM;
         }
+  }
 #endif
         }
                
@@ -2213,6 +2219,8 @@ EDMA3_DRV_Result EDMA3_DRV_disableLogicalChannel (EDMA3_DRV_Handle hEdma,
         result = EDMA3_DRV_E_INVALID_PARAM;
         }
 
+  if (lCh < EDMA3_MAX_DMA_CH)
+  {
        /* Trigger type is Event */
     if ((EDMA3_DRV_TRIG_MODE_EVENT == trigMode)
        && ((drvObject->gblCfgParams.dmaChannelHwEvtMap [lCh/32U]
@@ -2221,6 +2229,7 @@ EDMA3_DRV_Result EDMA3_DRV_disableLogicalChannel (EDMA3_DRV_Handle hEdma,
         /* Channel was not mapped to any Hw Event. */
         result = EDMA3_DRV_E_INVALID_PARAM;
         }
+  }
 #endif
         }