History

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

Alexander Sverdlin committed 6 years ago

Commit 87f2d1c1 parent 9ae05221 file · +5 −5Browse files

Unified · Split

kernel/irq/irqdomain.c+5−5
@@ -1310,6 +1310,11 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain, · 1309 unmodified lines
1310 unsigned int irq_base,1310 unsigned int irq_base,
1311 unsigned int nr_irqs, void *arg)1311 unsigned int nr_irqs, void *arg)
1312{1312{
1313 if (!domain->ops->alloc) {
1314 pr_debug("domain->ops->alloc() is NULL\n");
1315 return -ENOSYS;
1316 }
1317
1313 return domain->ops->alloc(domain, irq_base, nr_irqs, arg);1318 return domain->ops->alloc(domain, irq_base, nr_irqs, arg);
1314}1319}
1315 1320
@@ -1347,11 +1352,6 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, · 31 unmodified lines
1347 return -EINVAL;1352 return -EINVAL;
1348 }1353 }
1349 1354
1350 if (!domain->ops->alloc) {
1351 pr_debug("domain->ops->alloc() is NULL\n");
1352 return -ENOSYS;
1353 }
1354
1355 if (realloc && irq_base >= 0) {1355 if (realloc && irq_base >= 0) {
1356 virq = irq_base;1356 virq = irq_base;
1357 } else {1357 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t