public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qed: fix division by zero in qed_init_wfq_param when all vports configured
@ 2026-04-29 15:11 Evgenii Burenchev
  2026-05-02  1:46 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Evgenii Burenchev @ 2026-04-29 15:11 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Evgenii Burenchev, andrew+netdev, davem, edumazet, kuba, pabeni,
	kees, horms, darinzon, bhelgaas, netdev, linux-kernel

In qed_init_wfq_param(), variable non_requested_count can become zero
when all vports already have configured flag set. This happens when
num_vports equals the number of configured vports.

The function then calculates left_rate_per_vp = total_left_rate /
non_requested_count, which causes division by zero.

Add a check for non_requested_count == 0 before the division. Return
error when no unconfigured vports exist to distribute bandwidth.

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

Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
---
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c
index 42c6dcfb1f0f..b287e04c8adc 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_dev.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c
@@ -5105,6 +5105,13 @@ static int qed_init_wfq_param(struct qed_hwfn *p_hwfn,
 
 	total_left_rate	= min_pf_rate - total_req_min_rate;
 
+	if (non_requested_count == 0) {
+		DP_VERBOSE(p_hwfn, NETIF_MSG_LINK,
+			   "All %d vports are already configured for WFQ, no unconfigured vports to distribute remaining bandwidth\n",
+			   num_vports);
+		return -EINVAL;
+	}
+
 	left_rate_per_vp = total_left_rate / non_requested_count;
 	if (left_rate_per_vp <  min_pf_rate / QED_WFQ_UNIT) {
 		DP_VERBOSE(p_hwfn, NETIF_MSG_LINK,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-02  1:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 15:11 [PATCH] qed: fix division by zero in qed_init_wfq_param when all vports configured Evgenii Burenchev
2026-05-02  1:46 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox