Patch "pinctrl: single: Fix potential division by zero" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    pinctrl: single: Fix potential division by zero

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pinctrl-single-fix-potential-division-by-zero.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d351a4cb44ca18f80181628abce30b2cd977df36
Author: Maxim Korotkov <korotkov.maxim.s@xxxxxxxxx>
Date:   Thu Nov 17 15:30:34 2022 +0300

    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@xxxxxxxxx>
    Reviewed-by: Tony Lindgren <tony@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221117123034.27383-1-korotkov.maxim.s@xxxxxxxxx
    Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 17aa0d542d92..d139cd9e6d13 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -726,7 +726,7 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
 
 	mux_bytes = pcs->width / BITS_PER_BYTE;
 
-	if (pcs->bits_per_mux) {
+	if (pcs->bits_per_mux && pcs->fmask) {
 		pcs->bits_per_pin = fls(pcs->fmask);
 		nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin;
 		num_pins_in_register = pcs->width / pcs->bits_per_pin;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux