net/ena/base: check null meta desc
authorMichal Krawczyk <mk@semihalf.com>
Thu, 17 Sep 2020 05:30:30 +0000 (07:30 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:09 +0000 (19:19 +0200)
Static code analysis showed up, that it's possible for meta_desc being
NULL. To avoid dereference of the NULL pointer, extra check was added if
the pointer is in fact valid.

Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Igor Chauskin <igorch@amazon.com>
Reviewed-by: Guy Tzalik <gtzalik@amazon.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/net/ena/base/ena_eth_com.c

index 9c4e613..b6821a7 100644 (file)
@@ -268,6 +268,9 @@ static int ena_com_create_meta(struct ena_com_io_sq *io_sq,
        struct ena_eth_io_tx_meta_desc *meta_desc = NULL;
 
        meta_desc = get_sq_desc(io_sq);
+       if (unlikely(!meta_desc))
+               return ENA_COM_FAULT;
+
        memset(meta_desc, 0x0, sizeof(struct ena_eth_io_tx_meta_desc));
 
        meta_desc->len_ctrl |= ENA_ETH_IO_TX_META_DESC_META_DESC_MASK;