[PATCH] net/qede/base: fix division by zero

Bulatov Mark ms.bulatov7 at gmail.com
Fri Nov 13 15:07:02 CET 2026


From: Mark Bulatov <ms.bulatov7 at gmail.com>

In the ecore_init_wfq_param() function, calculating left_rate_per_vp will
result in a division by zero if num_vports and req_count are configured
to have equal values.

Fix this by adding an extra check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: ec94dbc573 ("qede: add base driver")
Cc: stable at dpdk.org

Signed-off-by: Alexey Simakov <bigalex934 at gmail.com>
Signed-off-by: Mark Bulatov <ms.bulatov7 at gmail.com>
---
 drivers/net/qede/base/ecore_dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c
index e895dee405..2082971b0b 100644
--- a/drivers/net/qede/base/ecore_dev.c
+++ b/drivers/net/qede/base/ecore_dev.c
@@ -6481,6 +6481,13 @@ static enum _ecore_status_t ecore_init_wfq_param(struct ecore_hwfn *p_hwfn,
 		return ECORE_INVAL;
 	}
 
+	/* Validate non_requested_count is non-zero */
+	if (non_requested_count == 0) {
+		DP_VERBOSE(p_hwfn, ECORE_MSG_LINK,
+			   "The number of vports is equal to the number of requests\n");
+		return ECORE_INVAL;
+	}
+
 	/* Data left for non requested vports */
 	total_left_rate = min_pf_rate - total_req_min_rate;
 	left_rate_per_vp = total_left_rate / non_requested_count;
-- 
2.39.5



More information about the dev mailing list