Skip to contentSkip to conversation

gpio: pca953x: Fix uninitialized pending variable

PATCH Applied Ye Li 3 participants 3 messages Sep 23, 2020 – Sep 24, 2020 GPIO

lore
Share & tools
lore

Ye Li

author
#0 lore raw

PATCH 1/1 gpio: pca953x: Fix uninitialized pending variable

When pca953x_irq_pending returns false, the pending parameter won't be set. But pca953x_irq_handler continues using this uninitialized variable as pending irqs and will cause problem.
Fix the issue by initializing pending to 0.

Fixes 064c73afe738 ("gpio: pca953x: Synchronize interrupt handler properly")
---
 drivers/gpio/gpio-pca953x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pca953x.c +1 -1
index b5c3e566..0a49ab6 100644
@@ -814,7 +814,7 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
 {
 	struct pca953x_chip *chip = devid;
 	struct gpio_chip *gc = &chip->gpio_chip;
-	DECLARE_BITMAP(pending, MAX_LINE);
+	DECLARE_BITMAP(pending, MAX_LINE) = {};
 	int level;
 	bool ret;
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Ye Li

When pca953x_irq_pending returns false, the pending parameter won't be set. But pca953x_irq_handler continues using this uninitialized variable as pending irqs and will cause problem.
Fix the issue by initializing pending to 0.

Oops, seems you are right. Thanks!

Quoted 22 lines
Fixes 064c73afe738 ("gpio: pca953x: Synchronize interrupt handler properly")
---
 drivers/gpio/gpio-pca953x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pca953x.c +1 -1
index b5c3e566..0a49ab6 100644
@@ -814,7 +814,7 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
 {
 	struct pca953x_chip *chip = devid;
 	struct gpio_chip *gc = &chip->gpio_chip;
-	DECLARE_BITMAP(pending, MAX_LINE);
+	DECLARE_BITMAP(pending, MAX_LINE) = {};
 	int level;
 	bool ret;
 
Signature · 1 line
2.7.4
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to Ye Li
Quoted 26 lines · Ye Li

When pca953x_irq_pending returns false, the pending parameter won't be set. But pca953x_irq_handler continues using this uninitialized variable as pending irqs and will cause problem.
Fix the issue by initializing pending to 0.

Fixes 064c73afe738 ("gpio: pca953x: Synchronize interrupt handler properly")
---
 drivers/gpio/gpio-pca953x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pca953x.c +1 -2
index b5c3e566..0a49ab6 100644
@@ -814,7 +814,7 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
 {
        struct pca953x_chip *chip = devid;
        struct gpio_chip *gc = &chip->gpio_chip;
-       DECLARE_BITMAP(pending, MAX_LINE);
+       DECLARE_BITMAP(pending, MAX_LINE) = {};
        int level;
        bool ret;
 
--
Quoted 2 lines

2.7.4

Queued for fixes, thanks!

Bartosz