]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
RDMA: hfi1: fix possible divide-by-zero in find_hw_thread_mask()
authorYury Norov [NVIDIA] <yury.norov@gmail.com>
Wed, 4 Jun 2025 19:39:38 +0000 (15:39 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:28:26 +0000 (16:28 +0200)
commit89fdac333a17ed990b41565630ef4791782e02f5
treef8e6cffecf856f71674f26c86205dfb67010878b
parent773612b1edf33b1d81146f1e151839a83d97be9a
RDMA: hfi1: fix possible divide-by-zero in find_hw_thread_mask()

[ Upstream commit 59f7d2138591ef8f0e4e4ab5f1ab674e8181ad3a ]

The function divides number of online CPUs by num_core_siblings, and
later checks the divider by zero. This implies a possibility to get
and divide-by-zero runtime error. Fix it by moving the check prior to
division. This also helps to save one indentation level.

Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
Link: https://patch.msgid.link/20250604193947.11834-3-yury.norov@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/hfi1/affinity.c