net/qede/base: add check for DMA engine state
authorRasesh Mody <rasesh.mody@cavium.com>
Sat, 7 Oct 2017 06:31:00 +0000 (23:31 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 12 Oct 2017 00:36:58 +0000 (01:36 +0100)
Check DMA engine state to verify it is not called before it is
initialized

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore_hw.c

index d6217d8..bc0138f 100644 (file)
@@ -789,6 +789,15 @@ ecore_dmae_execute_command(struct ecore_hwfn *p_hwfn,
                return ECORE_SUCCESS;
        }
 
+       if (!cmd) {
+               DP_NOTICE(p_hwfn, true,
+                         "ecore_dmae_execute_sub_operation failed. Invalid state. source_addr 0x%lx, destination addr 0x%lx, size_in_dwords 0x%x\n",
+                         (unsigned long)src_addr,
+                         (unsigned long)dst_addr,
+                         length_cur);
+               return ECORE_INVAL;
+       }
+
        ecore_dmae_opcode(p_hwfn,
                          (src_type == ECORE_DMAE_ADDRESS_GRC),
                          (dst_type == ECORE_DMAE_ADDRESS_GRC), p_params);