[PATCH] gpio: mpfs: reject unsupported interrupt types
Isaac Adjei via B4 Relay
devnull+code.isaacadjei.me at kernel.org
Thu Nov 5 00:16:51 PST 2026
From: Isaac Adjei <code at isaacadjei.me>
The switch statement in mpfs_gpio_irq_set_type() does not handle
unsupported interrupt types. For example, IRQ_TYPE_NONE is not listed.
When an unsupported type is passed, interrupt_type remains
uninitialised. Its undefined value is then written to the GPIO control
register. The function still returns 0, making the caller believe the
operation succeeded.
Add a default case to return -EINVAL for unsupported interrupt types.
Smatch reported the following warning:
drivers/gpio/gpio-mpfs.c:144 mpfs_gpio_irq_set_type() error: uninitialized symbol 'interrupt_type'.
I built the driver with W=1 and got no warnings. I also reran Smatch
and confirmed that the warning was resolved.
This is compile-tested only. I do not have access to PolarFire SoC
hardware for runtime testing.
Fixes: e57b53f0f36a ("gpio: mpfs: Add interrupt support")
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Dan Carpenter <error27 at gmail.com>
Closes: https://lore.kernel.org/r/202411080149.bOpayvf6-lkp@intel.com/
Signed-off-by: Isaac Adjei <code at isaacadjei.me>
---
drivers/gpio/gpio-mpfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-mpfs.c b/drivers/gpio/gpio-mpfs.c
index 7f0751d7b..0b7a48e0a 100644
--- a/drivers/gpio/gpio-mpfs.c
+++ b/drivers/gpio/gpio-mpfs.c
@@ -138,6 +138,8 @@ static int mpfs_gpio_irq_set_type(struct irq_data *data, unsigned int type)
case IRQ_TYPE_LEVEL_LOW:
interrupt_type = MPFS_GPIO_TYPE_INT_LEVEL_LOW;
break;
+ default:
+ return -EINVAL;
}
regmap_update_bits(mpfs_gpio->regs, MPFS_GPIO_CTRL(gpio_index),
---
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
change-id: 20261105-gpio-mpfs-irq-type-e36c823bcfd6
Best regards,
--
Isaac Adjei <code at isaacadjei.me>
More information about the linux-riscv
mailing list