[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <158366925336.28353.5904197587974966508.tip-bot2@tip-bot2>
Date: Sun, 08 Mar 2020 12:07:33 -0000
From: "tip-bot2 for Alexander Sverdlin" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Alexander Sverdlin <alexander.sverdlin@...ia.com>,
Thomas Gleixner <tglx@...utronix.de>, x86 <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: [tip: irq/core] genirq/irqdomain: Check pointer in
irq_domain_alloc_irqs_hierarchy()
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 87f2d1c662fa1761359fdf558246f97e484d177a
Gitweb: https://git.kernel.org/tip/87f2d1c662fa1761359fdf558246f97e484d177a
Author: Alexander Sverdlin <alexander.sverdlin@...ia.com>
AuthorDate: Fri, 06 Mar 2020 18:47:20 +01:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Sun, 08 Mar 2020 13:03:41 +01:00
genirq/irqdomain: Check pointer in irq_domain_alloc_irqs_hierarchy()
irq_domain_alloc_irqs_hierarchy() has 3 call sites in the compilation unit
but only one of them checks for the pointer which is being dereferenced
inside the called function. Move the check into the function. This allows
for catching the error instead of the following crash:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
PC is at 0x0
LR is at gpiochip_hierarchy_irq_domain_alloc+0x11f/0x140
...
[<c06c23ff>] (gpiochip_hierarchy_irq_domain_alloc)
[<c0462a89>] (__irq_domain_alloc_irqs)
[<c0462dad>] (irq_create_fwspec_mapping)
[<c06c2251>] (gpiochip_to_irq)
[<c06c1c9b>] (gpiod_to_irq)
[<bf973073>] (gpio_irqs_init [gpio_irqs])
[<bf974048>] (gpio_irqs_exit+0xecc/0xe84 [gpio_irqs])
Code: bad PC value
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@...ia.com>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Link: https://lkml.kernel.org/r/20200306174720.82604-1-alexander.sverdlin@nokia.com
---
kernel/irq/irqdomain.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index fdfc213..35b8d97 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1310,6 +1310,11 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
unsigned int irq_base,
unsigned int nr_irqs, void *arg)
{
+ if (!domain->ops->alloc) {
+ pr_debug("domain->ops->alloc() is NULL\n");
+ return -ENOSYS;
+ }
+
return domain->ops->alloc(domain, irq_base, nr_irqs, arg);
}
@@ -1347,11 +1352,6 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
return -EINVAL;
}
- if (!domain->ops->alloc) {
- pr_debug("domain->ops->alloc() is NULL\n");
- return -ENOSYS;
- }
-
if (realloc && irq_base >= 0) {
virq = irq_base;
} else {
Powered by blists - more mailing lists