diff mbox series

gpio: mpfs: reject unsupported interrupt types

Message ID 20261105-gpio-mpfs-irq-type-v1-1-cbb2b0b2a807@isaacadjei.me
State New
Headers show
Series gpio: mpfs: reject unsupported interrupt types | expand

Commit Message

Isaac Adjei via B4 Relay Nov. 5, 2026, 8:16 a.m. UTC
From: Isaac Adjei <code@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@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202411080149.bOpayvf6-lkp@intel.com/
Signed-off-by: Isaac Adjei <code@isaacadjei.me>
---
 drivers/gpio/gpio-mpfs.c | 2 ++
 1 file changed, 2 insertions(+)


---
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
change-id: 20261105-gpio-mpfs-irq-type-e36c823bcfd6

Best regards,

Comments

Bartosz Golaszewski Nov. 6, 2026, 9:43 a.m. UTC | #1
On Thu, 05 Nov 2026 08:16:51 +0000, Isaac Adjei wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] gpio: mpfs: reject unsupported interrupt types
      https://git.kernel.org/brgl/c/cfbd01eddaf5bfdd4f53560013fe830571a186e9

Best regards,
diff mbox series

Patch

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),