linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] gpio: pca953x: avoid to use uninitialized value pinctrl
@ 2022-12-10 22:05 Andy Shevchenko
  2022-12-10 22:05 ` [PATCH v2 2/4] gpio: pca953x: avoid logically dead code Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-12-10 22:05 UTC (permalink / raw)
  To: Bartosz Golaszewski, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Haibo Chen, Andy Shevchenko

From: Haibo Chen <haibo.chen@nxp.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@nxp.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-30 21:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-10 22:05 [PATCH v2 1/4] gpio: pca953x: avoid to use uninitialized value pinctrl Andy Shevchenko
2022-12-10 22:05 ` [PATCH v2 2/4] gpio: pca953x: avoid logically dead code Andy Shevchenko
2022-12-10 22:06 ` [PATCH v2 3/4] gpio: pca953x: Clean up pcal6534_check_register() Andy Shevchenko
2022-12-10 22:06 ` [PATCH v2 4/4] gpio: pca953x: Remove unused PCAL953X_OUT_CONF from pcal6534_recalc_addr() Andy Shevchenko
2022-12-30 12:04 ` [PATCH v2 1/4] gpio: pca953x: avoid to use uninitialized value pinctrl Andy Shevchenko
2022-12-30 12:48   ` Bartosz Golaszewski
2022-12-30 21:36     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).