[PATCH 1/2] gpio: sifive: Unregister the GPIO chip on unbind

Tian Xuechen 202300460064 at mail.sdu.edu.cn
Sat Nov 28 03:02:28 PST 2026


From: Tian Xuechen <202300460064 at mail.sdu.edu.cn>

The SiFive driver registers a GPIO chip embedded in managed storage.
The chip remains registered when the driver unbinds and that storage
is released.

Use devm_gpiochip_add_data() to unregister the chip on unbind.

This issue was found by our static analysis tool under development.

Fixes: 96868dce644d ("gpio/sifive: Add GPIO driver for SiFive SoCs")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
 drivers/gpio/gpio-sifive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
index 0b52b20e5136..f7564bcce9db 100644
--- a/drivers/gpio/gpio-sifive.c
+++ b/drivers/gpio/gpio-sifive.c
@@ -252,7 +252,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
 	girq->handler = handle_bad_irq;
 	girq->default_type = IRQ_TYPE_NONE;
 
-	return gpiochip_add_data(&chip->gen_gc.gc, chip);
+	return devm_gpiochip_add_data(dev, &chip->gen_gc.gc, chip);
 }
 
 static const struct of_device_id sifive_gpio_match[] = {
-- 
2.43.0




More information about the linux-riscv mailing list