From dc7920c76c1cabf702df03a20d15a5dc89b38fea Mon Sep 17 00:00:00 2001 From: Martin Spinler Date: Wed, 1 Apr 2020 08:38:01 +0200 Subject: [PATCH] net/nfb: check array size before access The driver wrongly assumed the presence of at least one rxmac in every firmware and accessed to non-existing unit Signed-off-by: Martin Spinler Acked-by: Jakub Neruda --- drivers/net/nfb/nfb_rxmode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfb/nfb_rxmode.c b/drivers/net/nfb/nfb_rxmode.c index 3327c8272b..2d0b613d21 100644 --- a/drivers/net/nfb/nfb_rxmode.c +++ b/drivers/net/nfb/nfb_rxmode.c @@ -54,7 +54,8 @@ nfb_eth_promiscuous_get(struct rte_eth_dev *dev) struct nc_rxmac_status status; status.mac_filter = RXMAC_MAC_FILTER_PROMISCUOUS; - nc_rxmac_read_status(internals->rxmac[0], &status); + if (internals->max_rxmac > 0) + nc_rxmac_read_status(internals->rxmac[0], &status); return (status.mac_filter == RXMAC_MAC_FILTER_PROMISCUOUS); } @@ -102,7 +103,9 @@ nfb_eth_allmulticast_get(struct rte_eth_dev *dev) struct nc_rxmac_status status; status.mac_filter = RXMAC_MAC_FILTER_PROMISCUOUS; - nc_rxmac_read_status(internals->rxmac[0], &status); + + if (internals->max_rxmac > 0) + nc_rxmac_read_status(internals->rxmac[0], &status); return (status.mac_filter == RXMAC_MAC_FILTER_TABLE_BCAST_MCAST); } -- 2.20.1