misrac fix 2 for 4.2.0 (PRSDK-3354)
[keystone-rtos/edma3_lld.git] / packages / ti / sdo / edma3 / drv / src / edma3_drv_adv.c
index f8f380887907271e68e6a1b1573b8921d2d0367d..55edc54e4a76056e1441d56fde0b5d34c1a5a139 100755 (executable)
@@ -213,7 +213,9 @@ EDMA3_DRV_Result EDMA3_DRV_linkChannel (EDMA3_DRV_Handle hEdma,
 #endif
     }
 
-       if (EDMA3_DRV_SOK == result)
+    if (EDMA3_DRV_SOK == result)
+    {
+        if((lCh1 < EDMA3_MAX_LOGICAL_CH) && (lCh2 < EDMA3_MAX_LOGICAL_CH))
         {
         paRAM1Id = edma3DrvChBoundRes[edma3Id][lCh1].paRAMId;
         paRAM2Id = edma3DrvChBoundRes[edma3Id][lCh2].paRAMId;
@@ -227,7 +229,12 @@ EDMA3_DRV_Result EDMA3_DRV_linkChannel (EDMA3_DRV_Handle hEdma,
             {
             result = EDMA3_DRV_E_INVALID_PARAM;
             }
-               }
+        }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
     if (result == EDMA3_DRV_SOK)
         {
@@ -327,27 +334,34 @@ EDMA3_DRV_Result EDMA3_DRV_unlinkChannel (EDMA3_DRV_Handle hEdma, uint32_t lCh)
 #endif
     }
 
-       if (EDMA3_DRV_SOK == result)
+    if (EDMA3_DRV_SOK == result)
+    {
+        if(lCh < EDMA3_MAX_LOGICAL_CH)
         {
-        paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
-        if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+            paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
+            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
             {
-            result = EDMA3_DRV_E_INVALID_PARAM;
+                result = EDMA3_DRV_E_INVALID_PARAM;
             }
-               else
-               {
-               /* Get the Link-bcntReload PaRAM set entry */
-               linkBcntReld = (uint32_t)(*((&globalRegs->PARAMENTRY [paRAMId].OPT)
-                                                       + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD));
+            else
+            {
+                /* Get the Link-bcntReload PaRAM set entry */
+                linkBcntReld = (uint32_t)(*((&globalRegs->PARAMENTRY [paRAMId].OPT)
+                                                    + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD));
 
-               /* Remove any linking */
-               linkBcntReld |= 0xFFFFU;
+                /* Remove any linking */
+                linkBcntReld |= 0xFFFFU;
 
-               /* Store it back */
-               *((&globalRegs->PARAMENTRY[paRAMId].OPT)
-                           + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD) = linkBcntReld;
-               }
-               }
+                /* Store it back */
+                *((&globalRegs->PARAMENTRY[paRAMId].OPT)
+                            + EDMA3_DRV_PARAM_ENTRY_LINK_BCNTRLD) = linkBcntReld;
+            }
+        }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
 #ifdef EDMA3_INSTRUMENTATION_ENABLED
     EDMA3_LOG_EVENT(&DVTEvent_Log,"EDMA3",
@@ -790,14 +804,21 @@ EDMA3_DRV_Result EDMA3_DRV_getPaRAM (EDMA3_DRV_Handle hEdma,
         }
 #endif
     }
-       if (EDMA3_DRV_SOK == result)
+    if (EDMA3_DRV_SOK == result)
+    {
+        if(lCh < EDMA3_MAX_LOGICAL_CH)
         {
-        paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
-        if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+            paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
+            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
             {
-            result = EDMA3_DRV_E_INVALID_PARAM;
+                result = EDMA3_DRV_E_INVALID_PARAM;
             }
-               }
+        }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
     if (result == EDMA3_DRV_SOK)
         {
@@ -874,18 +895,25 @@ EDMA3_DRV_Result EDMA3_DRV_setPaRAMEntry (EDMA3_DRV_Handle hEdma,
 #endif
     }
     if (EDMA3_DRV_SOK == result)
+    {
+        if(lCh < EDMA3_MAX_LOGICAL_CH)
         {
-        paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
-        if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
+            paRAMId = edma3DrvChBoundRes[edma3Id][lCh].paRAMId;
+            if ((paRAMId < 0) || (paRAMId >= drvObject->gblCfgParams.numPaRAMSets))
             {
             result = EDMA3_DRV_E_INVALID_PARAM;
             }
-        else
+            else
             {
             *((&globalRegs->PARAMENTRY[paRAMId].OPT) +
                                        (uint32_t)paRAMEntry) = newPaRAMEntryVal;
             }
-               }
+       }
+        else
+        {
+            result = EDMA3_DRV_E_INVALID_PARAM;
+        }
+    }
 
 #ifdef EDMA3_INSTRUMENTATION_ENABLED
     EDMA3_LOG_EVENT(&DVTEvent_Log,"EDMA3",