From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 1/4] net/failsafe: avoid rte_memcpy if rte_realloc fails Date: Tue, 6 Nov 2018 11:30:02 -0800 Message-ID: <20181106193005.5383-2-stephen@networkplumber.org> References: <20181106193005.5383-1-stephen@networkplumber.org> Cc: Stephen Hemminger To: dev@dpdk.org Return-path: Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id C2E492BE2 for ; Tue, 6 Nov 2018 20:30:09 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id u10-v6so818289pfn.9 for ; Tue, 06 Nov 2018 11:30:09 -0800 (PST) In-Reply-To: <20181106193005.5383-1-stephen@networkplumber.org> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There is a potential issue seen by static tools if number of multicast addresses is zero, and rte_realloc of zero size fails (ie returns NULL). This won't happen in real world for a couple of reasons: Azure doesn't support multicast (ie this is dead code); and rte_realloc of zero size will never fail, but safe to just always return -ENOMEM of realloc fails. Coverity issue: 323487 Fixes: 901efc0da925 ("net/failsafe: support multicast address list set") Signed-off-by: Stephen Hemminger --- drivers/net/failsafe/failsafe_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 7f8bcd4c69f4..a20953a662e1 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -1155,7 +1155,7 @@ fs_set_mc_addr_list(struct rte_eth_dev *dev, mcast_addrs = rte_realloc(PRIV(dev)->mcast_addrs, nb_mc_addr * sizeof(PRIV(dev)->mcast_addrs[0]), 0); - if (mcast_addrs == NULL && nb_mc_addr > 0) { + if (mcast_addrs == NULL) { ret = -ENOMEM; goto rollback; } -- 2.17.1