net/nfb: check rxmac array size

Message ID 1585723081-17392-1-git-send-email-neruda@netcope.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/nfb: check rxmac array size |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK

Commit Message

Jakub Neruda April 1, 2020, 6:38 a.m. UTC
  From: Martin Spinler <spinler@cesnet.cz>

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>
  

Comments

Ferruh Yigit April 1, 2020, 5:48 p.m. UTC | #1
On 4/1/2020 7:38 AM, Jakub Neruda wrote:
> From: Martin Spinler <spinler@cesnet.cz>
> 
> 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>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/nfb/nfb_rxmode.c b/drivers/net/nfb/nfb_rxmode.c
index 3327c8272..2d0b613d2 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);
 }