]> 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:26:00 +0000 (16:26 +0200)
commit4b4317b0d758ff92ba96f4e448a8992a6fe607bf
treeb3ba3b64f9268eaa94c9c122f7863cee00a45b14
parent9923fde7bf562d4f88b93d1a0f390b22ee630236
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