]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
qed: fix division by zero in qed_init_wfq_param when all vports are configured
authorEvgenii Burenchev <evg28bur@yandex.ru>
Thu, 7 May 2026 14:55:17 +0000 (17:55 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 May 2026 01:11:06 +0000 (18:11 -0700)
In qed_init_wfq_param(), variable non_requested_count can become zero
when the number of vports with the configured flag set (including the
current vport being configured) equals total num_vports. This happens
when configuring the last unconfigured vport or when re-configuring
an already configured vport.

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

Fix this by skipping the division when non_requested_count is zero.
In that case, there is no remaining bandwidth to distribute, so just
record the configuration for the current vport and return success.

Fixes: bcd197c81f63 ("qed: Add vport WFQ configuration APIs")
Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
Link: https://patch.msgid.link/20260507145520.23106-1-evg28bur@yandex.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/qlogic/qed/qed_dev.c

index 42c6dcfb1f0fa5316e2772022423618edbc42e8e..dd75c47758e1a30f0c63658ea832bf40caba553a 100644 (file)
@@ -5103,6 +5103,13 @@ static int qed_init_wfq_param(struct qed_hwfn *p_hwfn,
                return -EINVAL;
        }
 
+       /* All vports are already or become configured, nothing to distribute */
+       if (non_requested_count == 0) {
+               p_hwfn->qm_info.wfq_data[vport_id].min_speed = req_rate;
+               p_hwfn->qm_info.wfq_data[vport_id].configured = true;
+               return 0;
+       }
+
        total_left_rate = min_pf_rate - total_req_min_rate;
 
        left_rate_per_vp = total_left_rate / non_requested_count;