From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CD12269833; Tue, 8 Apr 2025 11:24:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744111496; cv=none; b=Q1P2FIbaGTSYL2faB3a3835tRTDCzETqn0CokY7j6mWDgU4/FfTYy9T6MD32Nu5VMFAOhF0uk1WAH+XuediB6bEUaM7GxayJYrVxdC5x/xWPA5GiQfZ8kuKuAACHCIYLhhdqc3m7fLkaG4SFuqoy90+sfBQ8LCINdk/+rujK1R8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744111496; c=relaxed/simple; bh=FXVVh05W0skyIWgcDe0c1+Hh4Ohxk8otwQwYR/MLSEc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=br5FFO1gE838FxPhv9lmkqHXkGiPzz9jVc+NwI8OHVb5RWo5foAZ7HnLNy7Al0wGaAVBpd6kM91kdKLo42T5EtIq5cFCtnSajWMCkdvd9TllPfUxDaMtezqHtEJVRhWm8OD8eDebnbMVneFHE6SRqTwhrNXDKsRGpxNhe0L3xag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0hwNseTb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0hwNseTb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9314C4CEE7; Tue, 8 Apr 2025 11:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744111496; bh=FXVVh05W0skyIWgcDe0c1+Hh4Ohxk8otwQwYR/MLSEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0hwNseTbqRi+f6DW6AtyzFks9HdHOCuulE5AEYnA3oenwvWMzp7YH+xMrW9AAjg1i 6Cwb5R3/YKqklj1D91zMqfMGpIrKkp6/P6AoSQG14dmDetptLrNRdOtve2idFNrtHk zrmg6qoJijSYlqrVutFhdHvAya9cS0+f6F1pkNAo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Zhandarovich , Lee Jones , Sasha Levin Subject: [PATCH 6.14 425/731] mfd: sm501: Switch to BIT() to mitigate integer overflows Date: Tue, 8 Apr 2025 12:45:22 +0200 Message-ID: <20250408104924.159611093@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104914.247897328@linuxfoundation.org> References: <20250408104914.247897328@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Zhandarovich [ 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 Link: https://lore.kernel.org/r/20250115171206.20308-1-n.zhandarovich@fintech.ru Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/sm501.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 0469e85d72cff..7ee293b09f628 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -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; -- 2.39.5