net/i40e/base: avoid potential null pointer dereference
authorJingjing Wu <jingjing.wu@intel.com>
Tue, 27 Jun 2017 13:29:13 +0000 (21:29 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 6 Jul 2017 13:00:57 +0000 (15:00 +0200)
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
drivers/net/i40e/base/i40e_common.c

index 3f3b275..78ed2a8 100644 (file)
@@ -330,13 +330,15 @@ void i40e_debug_aq(struct i40e_hw *hw, enum i40e_debug_mask mask, void *desc,
                   void *buffer, u16 buf_len)
 {
        struct i40e_aq_desc *aq_desc = (struct i40e_aq_desc *)desc;
-       u16 len = LE16_TO_CPU(aq_desc->datalen);
        u8 *buf = (u8 *)buffer;
+       u16 len;
        u16 i = 0;
 
        if ((!(mask & hw->debug_mask)) || (desc == NULL))
                return;
 
+       len = LE16_TO_CPU(aq_desc->datalen);
+
        i40e_debug(hw, mask,
                   "AQ CMD: opcode 0x%04X, flags 0x%04X, datalen 0x%04X, retval 0x%04X\n",
                   LE16_TO_CPU(aq_desc->opcode),