[PATCH] gpio: mxs: Fix potential stale handler on probe failure

Tian Xuechen 202300460064 at mail.sdu.edu.cn
Wed Dec 2 04:52:46 PST 2026


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

The chained handler is installed before GPIO initialization and
registration can fail. Those failures release the port without clearing
the handler, leaving its handler data pointing to freed memory.

Install the handler after the last fallible initialization step.

Fixes: 8d7cf8370d5f ("gpio/mxs: Change gpio-mxs into an upstanding gpio driver")
Signed-off-by: Tian Xuechen <202300460064 at mail.sdu.edu.cn>
---
 drivers/gpio/gpio-mxs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 09e16ce6a9fa..70039181da15 100644
--- a/drivers/gpio/gpio-mxs.c
+++ b/drivers/gpio/gpio-mxs.c
@@ -317,10 +317,6 @@ static int mxs_gpio_probe(struct platform_device *pdev)
 	if (err < 0)
 		goto out_irqdomain_remove;
 
-	/* setup one handler for each entry */
-	irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler,
-					 port);
-
 	config = (struct gpio_generic_chip_config) {
 		.dev = &pdev->dev,
 		.sz = 4,
@@ -342,6 +338,10 @@ static int mxs_gpio_probe(struct platform_device *pdev)
 	if (err)
 		goto out_irqdomain_remove;
 
+	/* setup one handler for each entry */
+	irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler,
+					 port);
+
 	return 0;
 
 out_irqdomain_remove:

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244



More information about the linux-arm-kernel mailing list