net/nfb: check array size before access
authorMartin Spinler <spinler@cesnet.cz>
Wed, 1 Apr 2020 06:38:01 +0000 (08:38 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:06 +0000 (13:57 +0200)
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 <spinler@cesnet.cz>
Acked-by: Jakub Neruda <neruda@netcope.com>
drivers/net/nfb/nfb_rxmode.c

index 3327c82..2d0b613 100644 (file)
@@ -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);
 }