]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
pinctrl: single: Fix potential division by zero
authorMaxim Korotkov <korotkov.maxim.s@gmail.com>
Thu, 17 Nov 2022 12:30:34 +0000 (15:30 +0300)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 13:02:51 +0000 (14:02 +0100)
commita0be62e77e9a08c7fa5b4cb6aa0279ef1c9cad2d
tree78659412bea56db08074bd37e28b760e7fe89c7d
parent3c217561f812c4be9a03d30396504054bae4473a
pinctrl: single: Fix potential division by zero

[ Upstream commit 64c150339e7f6c5cbbe8c17a56ef2b3902612798 ]

There is a possibility of dividing by zero due to the pcs->bits_per_pin
if pcs->fmask() also has a value of zero and called fls
from asm-generic/bitops/builtin-fls.h or arch/x86/include/asm/bitops.h.
The function pcs_probe() has the branch that assigned to fmask 0 before
pcs_allocate_pin_table() was called

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

Fixes: 4e7e8017a80e ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules")
Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20221117123034.27383-1-korotkov.maxim.s@gmail.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit d86d698925456f88f44183c70ce1b46656a28fed)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
drivers/pinctrl/pinctrl-single.c