]> git.baikalelectronics.ru Git - 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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Dec 2022 10:23:04 +0000 (11:23 +0100)
commit1b09140887582198be13f9f83522c34f8d081142
tree396082f2d152b0f5a0949d40e643a848a6322ac9
parentfb13f93cdf723d3bfce18b8d4824af8f25979ff0
pinctrl: single: Fix potential division by zero

[ Upstream commit 49bf5be781c56bc47458b05441fb78b8e2aedf51 ]

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: d0c1654f1cd9 ("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>
drivers/pinctrl/pinctrl-single.c