[PATCH v2 02/10] net/nfp: fix malloc name problem in secondary process
Chaoyong He
chaoyong.he at corigine.com
Sat Oct 12 04:40:59 CEST 2024
The original logic keeps using the same name parameter when malloc
memory in secondary process, which may cause error when using
multiple PF cards.
Fixes: 3b00109d2b65 ("net/nfp: add PF ID used to format symbols")
Cc: peng.zhang at corigine.com
Cc: stable at dpdk.org
Signed-off-by: Chaoyong He <chaoyong.he at corigine.com>
Reviewed-by: Long Wu <long.wu at corigine.com>
Reviewed-by: Peng Zhang <peng.zhang at corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 64a06440f5..3732abc9fe 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -2669,7 +2669,8 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
}
/* Allocate memory for the PF "device" */
- snprintf(name, sizeof(name), "nfp_pf%d", 0);
+ function_id = pci_dev->addr.function & 0x7;
+ snprintf(name, sizeof(name), "nfp_pf%d", function_id);
pf_dev = rte_zmalloc(name, sizeof(*pf_dev), 0);
if (pf_dev == NULL) {
PMD_INIT_LOG(ERR, "Can't allocate memory for the PF device");
@@ -2714,7 +2715,6 @@ nfp_pf_secondary_init(struct rte_pci_device *pci_dev)
}
/* Read the app ID of the firmware loaded */
- function_id = pci_dev->addr.function & 0x7;
snprintf(app_name, sizeof(app_name), "_pf%u_net_app_id", function_id);
app_fw_id = nfp_rtsym_read_le(sym_tbl, app_name, &ret);
if (ret != 0) {
--
2.39.1
More information about the dev
mailing list