Commit de2ab02d authored by Daniil Tatianin's avatar Daniil Tatianin Committed by sanglipeng
Browse files

qed/qed_dev: guard against a possible division by zero

stable inclusion
from stable-v5.10.176
commit 281e86e3fab69294e0a7467d0447d1b0468aa1fd
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8CHVQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=281e86e3fab69294e0a7467d0447d1b0468aa1fd



--------------------------------

[ Upstream commit 1a9dc561 ]

Previously we would divide total_left_rate by zero if num_vports
happened to be 1 because non_requested_count is calculated as
num_vports - req_count. Guard against this by validating num_vports at
the beginning and returning an error otherwise.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Fixes: bcd197c8 ("qed: Add vport WFQ configuration APIs")
Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230309201556.191392-1-d-tatianin@yandex-team.ru


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent c5347641
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment