Skip to content

Commit 64c1503

Browse files
ProjectMutilationlinusw
authored andcommitted
pinctrl: single: Fix potential division by zero
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: 4e7e801 ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules") Signed-off-by: Maxim Korotkov <[email protected]> Reviewed-by: Tony Lindgren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent eb70814 commit 64c1503

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pinctrl/pinctrl-single.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
727727

728728
mux_bytes = pcs->width / BITS_PER_BYTE;
729729

730-
if (pcs->bits_per_mux) {
730+
if (pcs->bits_per_mux && pcs->fmask) {
731731
pcs->bits_per_pin = fls(pcs->fmask);
732732
nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin;
733733
} else {

0 commit comments

Comments
 (0)