[PATCH] soc: fsl: qe: qe_ports_ic: Consolidate chained IRQ handler install/remove

Chen Ni posted 1 patch 2 weeks, 5 days ago
drivers/soc/fsl/qe/qe_ports_ic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] soc: fsl: qe: qe_ports_ic: Consolidate chained IRQ handler install/remove
Posted by Chen Ni 2 weeks, 5 days ago
The driver currently sets the handler data and the chained handler in
two separate steps. This creates a theoretical race window where an
interrupt could fire after the handler is set but before the data is
assigned, leading to a NULL pointer dereference.

Replace the two calls with irq_set_chained_handler_and_data() to set
both the handler and its data atomically under the irq_desc->lock.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 drivers/soc/fsl/qe/qe_ports_ic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qe/qe_ports_ic.c b/drivers/soc/fsl/qe/qe_ports_ic.c
index 61dd09fec6f6..8e2107e2cde5 100644
--- a/drivers/soc/fsl/qe/qe_ports_ic.c
+++ b/drivers/soc/fsl/qe/qe_ports_ic.c
@@ -114,8 +114,7 @@ static int qepic_probe(struct platform_device *pdev)
 	if (!data->host)
 		return -ENODEV;
 
-	irq_set_handler_data(irq, data);
-	irq_set_chained_handler(irq, qepic_cascade);
+	irq_set_chained_handler_and_data(irq, qepic_cascade, data);
 
 	return 0;
 }
-- 
2.25.1
Re: [PATCH] soc: fsl: qe: qe_ports_ic: Consolidate chained IRQ handler install/remove
Posted by Christophe Leroy (CS GROUP) 1 week, 2 days ago
On Mon, 19 Jan 2026 13:57:15 +0800, Chen Ni wrote:
> The driver currently sets the handler data and the chained handler in
> two separate steps. This creates a theoretical race window where an
> interrupt could fire after the handler is set but before the data is
> assigned, leading to a NULL pointer dereference.
> 
> Replace the two calls with irq_set_chained_handler_and_data() to set
> both the handler and its data atomically under the irq_desc->lock.
> 
> [...]

Applied, thanks!

[1/1] soc: fsl: qe: qe_ports_ic: Consolidate chained IRQ handler install/remove

Best regards,
-- 
Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Re: [PATCH] soc: fsl: qe: qe_ports_ic: Consolidate chained IRQ handler install/remove
Posted by Christophe Leroy (CS GROUP) 2 weeks, 5 days ago

Le 19/01/2026 à 06:57, Chen Ni a écrit :
> [Vous ne recevez pas souvent de courriers de nichen@iscas.ac.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
> 
> The driver currently sets the handler data and the chained handler in
> two separate steps. This creates a theoretical race window where an
> interrupt could fire after the handler is set but before the data is
> assigned, leading to a NULL pointer dereference.

I don't understand what you mean, how can this happen ?

irq_set_handler_data() is called _before_ irq_set_chained_handler(), so 
how could an interrupt fire _before_ the data is assigned ?

> 
> Replace the two calls with irq_set_chained_handler_and_data() to set
> both the handler and its data atomically under the irq_desc->lock.
> 
> Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
> ---
>   drivers/soc/fsl/qe/qe_ports_ic.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/fsl/qe/qe_ports_ic.c b/drivers/soc/fsl/qe/qe_ports_ic.c
> index 61dd09fec6f6..8e2107e2cde5 100644
> --- a/drivers/soc/fsl/qe/qe_ports_ic.c
> +++ b/drivers/soc/fsl/qe/qe_ports_ic.c
> @@ -114,8 +114,7 @@ static int qepic_probe(struct platform_device *pdev)
>          if (!data->host)
>                  return -ENODEV;
> 
> -       irq_set_handler_data(irq, data);
> -       irq_set_chained_handler(irq, qepic_cascade);
> +       irq_set_chained_handler_and_data(irq, qepic_cascade, data);
> 
>          return 0;
>   }
> --
> 2.25.1
>