mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-04-29 12:28:27 +02:00
mfd: sm501: Switch to BIT() to mitigate integer overflows
[ Upstream commit2d8cb9ffe1] 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:f61be273d3("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7ee71ef057
commit
a1fab9e649
+3
-3
@@ -920,7 +920,7 @@ static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
{
|
||||
struct sm501_gpio_chip *smchip = gpiochip_get_data(chip);
|
||||
struct sm501_gpio *smgpio = smchip->ourgpio;
|
||||
unsigned long bit = 1 << offset;
|
||||
unsigned long bit = BIT(offset);
|
||||
void __iomem *regs = smchip->regbase;
|
||||
unsigned long save;
|
||||
unsigned long val;
|
||||
@@ -946,7 +946,7 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
|
||||
struct sm501_gpio_chip *smchip = gpiochip_get_data(chip);
|
||||
struct sm501_gpio *smgpio = smchip->ourgpio;
|
||||
void __iomem *regs = smchip->regbase;
|
||||
unsigned long bit = 1 << offset;
|
||||
unsigned long bit = BIT(offset);
|
||||
unsigned long save;
|
||||
unsigned long ddr;
|
||||
|
||||
@@ -971,7 +971,7 @@ static int sm501_gpio_output(struct gpio_chip *chip,
|
||||
{
|
||||
struct sm501_gpio_chip *smchip = gpiochip_get_data(chip);
|
||||
struct sm501_gpio *smgpio = smchip->ourgpio;
|
||||
unsigned long bit = 1 << offset;
|
||||
unsigned long bit = BIT(offset);
|
||||
void __iomem *regs = smchip->regbase;
|
||||
unsigned long save;
|
||||
unsigned long val;
|
||||
|
||||
Reference in New Issue
Block a user