[PATCH 37/54] net/bnxt: avoid potential segfault in VFR handling
Manish Kurup
manish.kurup at broadcom.com
Tue Sep 30 02:35:47 CEST 2025
From: Peter Spreadborough <peter.spreadborough at broadcom.com>
1. Addresses crashes that were seen when using invalid
representor arguments. The crash would occur when unwinding
after a bnxt_pci_probe() failure.
2. If a representor port exists and an attempt is made to attach
the same port a crash would occur. This change adds a check
for an already existing port.
Signed-off-by: Peter Spreadborough <peter.spreadborough at broadcom.com>
Tested-by: Stephen Shi <stephen.shi at broadcom.com>
Reviewed-by: Shuanglin Wang <shuanglin.wang at broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde at broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli at broadcom.com>
Reviewed-by: Manish Kurup <manish.kurup at broadcom.com>
---
drivers/net/bnxt/bnxt_ethdev.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a395c2ab47..efecbba2c3 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -6905,16 +6905,9 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev,
return -ENOTSUP;
}
num_rep = eth_da->nb_representor_ports;
- if (num_rep > max_vf_reps) {
- PMD_DRV_LOG_LINE(ERR, "nb_representor_ports = %d > %d MAX VF REPS",
- num_rep, max_vf_reps);
- return -EINVAL;
- }
-
- if (num_rep >= RTE_MAX_ETHPORTS) {
- PMD_DRV_LOG_LINE(ERR,
- "nb_representor_ports = %d > %d MAX ETHPORTS",
- num_rep, RTE_MAX_ETHPORTS);
+ if (num_rep > max_vf_reps || num_rep > RTE_MAX_ETHPORTS) {
+ PMD_DRV_LOG_LINE(ERR, "nb_representor_ports = %d > %d OR %d MAX VF REPS",
+ num_rep, max_vf_reps, RTE_MAX_ETHPORTS);
return -EINVAL;
}
@@ -6947,6 +6940,13 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev,
snprintf(name, sizeof(name), "net_%s_representor_%d",
pci_dev->device.name, eth_da->representor_ports[i]);
+ if (rte_eth_dev_allocated(name) != NULL) {
+ PMD_DRV_LOG_LINE(ERR,
+ "Ethernet device with name %s already allocated",
+ name);
+ return -EEXIST;
+ }
+
kvlist = rte_kvargs_parse(dev_args, bnxt_dev_args);
if (kvlist) {
/*
@@ -7083,7 +7083,13 @@ static int bnxt_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
num_rep = eth_da.nb_representor_ports;
PMD_DRV_LOG_LINE(DEBUG, "nb_representor_ports = %d",
- num_rep);
+ num_rep);
+ if (num_rep >= RTE_MAX_ETHPORTS) {
+ PMD_DRV_LOG_LINE(ERR,
+ "nb_representor_ports = %d > %d MAX ETHPORTS",
+ num_rep, RTE_MAX_ETHPORTS);
+ return -EINVAL;
+ }
/* We could come here after first level of probe is already invoked
* as part of an application bringup(OVS-DPDK vswitchd), so first check
--
2.39.5 (Apple Git-154)
More information about the dev
mailing list