]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mfd: sm501: Switch to BIT() to mitigate integer overflows
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Wed, 15 Jan 2025 17:12:06 +0000 (09:12 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Apr 2025 12:33:35 +0000 (14:33 +0200)
commitd77be51484c849acd27ec9e2113fae4a647be8c2
treedf5d441d27e04ef252e9c4ef9cde2d91b46a631a
parentf1b956685128a74a8d45411339ec1c40b1ed18e6
mfd: sm501: Switch to BIT() to mitigate integer overflows

[ Upstream commit 2d8cb9ffe18c2f1e5bd07a19cbce85b26c1d0cf0 ]

If offset end up being high enough, right hand expression in functions
like sm501_gpio_set() shifted left for that number of bits, may
not fit in int type.

Just in case, fix that by using BIT() both as an option safe from
overflow issues and to make this step look similar to other gpio
drivers.

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

Fixes: f61be273d369 ("sm501: add gpiolib support")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Link: https://lore.kernel.org/r/20250115171206.20308-1-n.zhandarovich@fintech.ru
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/sm501.c