[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221210220601.77648-1-andriy.shevchenko@linux.intel.com>
Date: Sun, 11 Dec 2022 00:05:58 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Haibo Chen <haibo.chen@....com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 1/4] gpio: pca953x: avoid to use uninitialized value pinctrl
From: Haibo Chen <haibo.chen@....com>
There is a variable pinctrl declared without initializer. And then
has the case (switch operation chose the default case) to directly
use this uninitialized value, this is not a safe behavior. So here
initialize the pinctrl as 0 to avoid this issue.
This is reported by Coverity.
Fixes: 13c5d4ce8060 ("gpio: pca953x: Add support for PCAL6534")
Signed-off-by: Haibo Chen <haibo.chen@....com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
v2: used default case (Andy)
drivers/gpio/gpio-pca953x.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index a59d61cd44b2..5299e5bb76d6 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -474,6 +474,9 @@ static u8 pcal6534_recalc_addr(struct pca953x_chip *chip, int reg, int off)
case PCAL6524_DEBOUNCE:
pinctrl = ((reg & PCAL_PINCTRL_MASK) >> 1) + 0x1c;
break;
+ default:
+ pinctrl = 0;
+ break;
}
return pinctrl + addr + (off / BANK_SZ);
--
2.35.1
Powered by blists - more mailing lists