* [PATCH] irqchip: ti-sci-inta: Fix kernel crash if irq_create_fwspec_mapping fail
@ 2019-06-04 10:17 ` Peter Ujfalusi
0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2019-06-04 10:17 UTC (permalink / raw)
To: lokeshvutla, tglx, jason, marc.zyngier
Cc: nm, t-kristo, ssantosh, linux-arm-kernel, linux-kernel
irq_create_fwspec_mapping() can fail, returning 0 as parent_virq. In this
case vint_desc is going to be NULL in ti_sci_inta_alloc_irq() which will
cause NULL pointer dereference.
Also note that irq_create_fwspec_mapping() returns 'unsigned int' so the
check '<=' was wrong.
Use -EINVAL if irq_create_fwspec_mapping() returned with 0.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/irqchip/irq-ti-sci-inta.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c
index 011b60a49e3f..ef4d625d2d80 100644
--- a/drivers/irqchip/irq-ti-sci-inta.c
+++ b/drivers/irqchip/irq-ti-sci-inta.c
@@ -159,9 +159,9 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
parent_fwspec.param[1] = vint_desc->vint_id;
parent_virq = irq_create_fwspec_mapping(&parent_fwspec);
- if (parent_virq <= 0) {
+ if (parent_virq == 0) {
kfree(vint_desc);
- return ERR_PTR(parent_virq);
+ return ERR_PTR(-EINVAL);
}
vint_desc->parent_virq = parent_virq;
--
Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] irqchip: ti-sci-inta: Fix kernel crash if irq_create_fwspec_mapping fail
@ 2019-06-04 10:17 ` Peter Ujfalusi
0 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2019-06-04 10:17 UTC (permalink / raw)
To: lokeshvutla, tglx, jason, marc.zyngier
Cc: nm, t-kristo, linux-kernel, linux-arm-kernel, ssantosh
irq_create_fwspec_mapping() can fail, returning 0 as parent_virq. In this
case vint_desc is going to be NULL in ti_sci_inta_alloc_irq() which will
cause NULL pointer dereference.
Also note that irq_create_fwspec_mapping() returns 'unsigned int' so the
check '<=' was wrong.
Use -EINVAL if irq_create_fwspec_mapping() returned with 0.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/irqchip/irq-ti-sci-inta.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c
index 011b60a49e3f..ef4d625d2d80 100644
--- a/drivers/irqchip/irq-ti-sci-inta.c
+++ b/drivers/irqchip/irq-ti-sci-inta.c
@@ -159,9 +159,9 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
parent_fwspec.param[1] = vint_desc->vint_id;
parent_virq = irq_create_fwspec_mapping(&parent_fwspec);
- if (parent_virq <= 0) {
+ if (parent_virq == 0) {
kfree(vint_desc);
- return ERR_PTR(parent_virq);
+ return ERR_PTR(-EINVAL);
}
vint_desc->parent_virq = parent_virq;
--
Peter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] irqchip: ti-sci-inta: Fix kernel crash if irq_create_fwspec_mapping fail
2019-06-04 10:17 ` Peter Ujfalusi
@ 2019-06-04 10:32 ` Marc Zyngier
-1 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2019-06-04 10:32 UTC (permalink / raw)
To: Peter Ujfalusi, lokeshvutla, tglx, jason
Cc: nm, t-kristo, ssantosh, linux-arm-kernel, linux-kernel
On 04/06/2019 11:17, Peter Ujfalusi wrote:
> irq_create_fwspec_mapping() can fail, returning 0 as parent_virq. In this
> case vint_desc is going to be NULL in ti_sci_inta_alloc_irq() which will
> cause NULL pointer dereference.
>
> Also note that irq_create_fwspec_mapping() returns 'unsigned int' so the
> check '<=' was wrong.
>
> Use -EINVAL if irq_create_fwspec_mapping() returned with 0.
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/irqchip/irq-ti-sci-inta.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c
> index 011b60a49e3f..ef4d625d2d80 100644
> --- a/drivers/irqchip/irq-ti-sci-inta.c
> +++ b/drivers/irqchip/irq-ti-sci-inta.c
> @@ -159,9 +159,9 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
> parent_fwspec.param[1] = vint_desc->vint_id;
>
> parent_virq = irq_create_fwspec_mapping(&parent_fwspec);
> - if (parent_virq <= 0) {
> + if (parent_virq == 0) {
> kfree(vint_desc);
> - return ERR_PTR(parent_virq);
> + return ERR_PTR(-EINVAL);
> }
> vint_desc->parent_virq = parent_virq;
>
>
Nice one. I've queued it as part of the stuff I need to send to Thomas
at the end of the week.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] irqchip: ti-sci-inta: Fix kernel crash if irq_create_fwspec_mapping fail
@ 2019-06-04 10:32 ` Marc Zyngier
0 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2019-06-04 10:32 UTC (permalink / raw)
To: Peter Ujfalusi, lokeshvutla, tglx, jason
Cc: nm, t-kristo, linux-kernel, linux-arm-kernel, ssantosh
On 04/06/2019 11:17, Peter Ujfalusi wrote:
> irq_create_fwspec_mapping() can fail, returning 0 as parent_virq. In this
> case vint_desc is going to be NULL in ti_sci_inta_alloc_irq() which will
> cause NULL pointer dereference.
>
> Also note that irq_create_fwspec_mapping() returns 'unsigned int' so the
> check '<=' was wrong.
>
> Use -EINVAL if irq_create_fwspec_mapping() returned with 0.
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
> drivers/irqchip/irq-ti-sci-inta.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c
> index 011b60a49e3f..ef4d625d2d80 100644
> --- a/drivers/irqchip/irq-ti-sci-inta.c
> +++ b/drivers/irqchip/irq-ti-sci-inta.c
> @@ -159,9 +159,9 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
> parent_fwspec.param[1] = vint_desc->vint_id;
>
> parent_virq = irq_create_fwspec_mapping(&parent_fwspec);
> - if (parent_virq <= 0) {
> + if (parent_virq == 0) {
> kfree(vint_desc);
> - return ERR_PTR(parent_virq);
> + return ERR_PTR(-EINVAL);
> }
> vint_desc->parent_virq = parent_virq;
>
>
Nice one. I've queued it as part of the stuff I need to send to Thomas
at the end of the week.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-04 10:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-04 10:17 [PATCH] irqchip: ti-sci-inta: Fix kernel crash if irq_create_fwspec_mapping fail Peter Ujfalusi
2019-06-04 10:17 ` Peter Ujfalusi
2019-06-04 10:32 ` Marc Zyngier
2019-06-04 10:32 ` Marc Zyngier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.