Skip to contentSkip to conversation

gpio: qixis-fpga: Fix error handling for devm_regmap_init_mmio()

PATCH Applied Felix Gu 2 participants 2 messages Mar 20 – Mar 23 GPIO

lore
Share & tools
lore

Felix Gu

author
#0 lore raw

PATCH 1/1 gpio: qixis-fpga: Fix error handling for devm_regmap_init_mmio()

devm_regmap_init_mmio() returns an ERR_PTR() on failure, not NULL. The original code checked for NULL which would never trigger on error, potentially leading to an invalid pointer dereference.
Use IS_ERR() and PTR_ERR() to properly handle the error case.

Fixes e88500247dc3 ("gpio: add QIXIS FPGA GPIO controller")
---
 drivers/gpio/gpio-qixis-fpga.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-qixis-fpga.c +2 -2
index 6e67f43ac0bd..3ced47db1521 100644
@@ -60,8 +60,8 @@ static int qixis_cpld_gpio_probe(struct platform_device *pdev)
 			return PTR_ERR(reg);
 
 		regmap = devm_regmap_init_mmio(&pdev->dev, reg, &regmap_config_8r_8v);
-		if (!regmap)
-			return -ENODEV;
+		if (IS_ERR(regmap))
+			return PTR_ERR(regmap);
 
 		/* In this case, the offset of our register is 0 inside the
 		 * regmap area that we just created.

---
base-commit: b5d083a3ed1e2798396d5e491432e887da8d4a06
change-id: 20260320-qixis-6abb25dea969

Best regards,

Signature · 1 line
Felix Gu <[email protected]>
#1 lore raw
Quoted 6 lines · Felix Gu

devm_regmap_init_mmio() returns an ERR_PTR() on failure, not NULL. The original code checked for NULL which would never trigger on error, potentially leading to an invalid pointer dereference.
Use IS_ERR() and PTR_ERR() to properly handle the error case.

Applied, thanks!

[1/1] gpio: qixis-fpga: Fix error handling for devm_regmap_init_mmio()

      https://git.kernel.org/brgl/c/8de4e0f44c638c66cdc5eeb4d5ab9acd61c31e4f

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>