From 4ad61424aaab783002947e4348afcd16ecb58327 Mon Sep 17 00:00:00 2001 From: Michal Krawczyk Date: Thu, 17 Sep 2020 07:30:30 +0200 Subject: [PATCH] net/ena/base: check null meta desc 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 Reviewed-by: Igor Chauskin Reviewed-by: Guy Tzalik Reviewed-by: Stephen Hemminger --- drivers/net/ena/base/ena_eth_com.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ena/base/ena_eth_com.c b/drivers/net/ena/base/ena_eth_com.c index 9c4e6133f5..b6821a7917 100644 --- a/drivers/net/ena/base/ena_eth_com.c +++ b/drivers/net/ena/base/ena_eth_com.c @@ -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; -- 2.20.1