irq_domain_chip_generic is allocating and indexing irq_chip_generic itself. However, the size of irq_chip_generic varies with number of irq_chip_types. This fixup moves irq_chip_generic helt by irq_domain_chip_generic to array of ptr and fixes the pointer arith used by irq_alloc_domain_generic_chip.
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselba...@gmail.com> --- Cc: Thomas Gleixner <t...@linutronix.de> Cc: Russell King - ARM Linux <li...@arm.linux.org.uk> Cc: Grant Likely <grant.lik...@linaro.org> Cc: Rob Herring <rob.herr...@calxeda.com> Cc: Rob Landley <r...@landley.net> Cc: Arnd Bergmann <a...@arndb.de> Cc: Jason Cooper <ja...@lakedaemon.net> Cc: Andrew Lunn <and...@lunn.ch> Cc: Jason Gunthorpe <jguntho...@obsidianresearch.com> Cc: Thomas Petazzoni <thomas.petazz...@free-electrons.com> Cc: Gregory Clement <gregory.clem...@free-electrons.com> Cc: Ezequiel Garcia <ezequiel.gar...@free-electrons.com> Cc: Maxime Ripard <maxime.rip...@free-electrons.com> Cc: Jean-Francois Moine <moin...@free.fr> Cc: Gerlando Falauto <gerlando.fala...@keymile.com> Cc: Uwe Kleine-Koenig <u.kleine-koe...@pengutronix.de> Cc: devicetree-disc...@lists.ozlabs.org Cc: linux-...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- include/linux/irq.h | 4 ++-- kernel/irq/generic-chip.c | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 7315155..fd2d7cb 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -730,7 +730,7 @@ enum irq_gc_flags { * @irq_flags_to_set: IRQ* flags to set on irq setup * @irq_flags_to_clear: IRQ* flags to clear on irq setup * @gc_flags: Generic chip specific setup flags - * @gc: Array of generic interrupt chips + * @gc: Array of pointer to generic interrupt chips */ struct irq_domain_chip_generic { unsigned int irqs_per_chip; @@ -738,7 +738,7 @@ struct irq_domain_chip_generic { unsigned int irq_flags_to_clear; unsigned int irq_flags_to_set; enum irq_gc_flags gc_flags; - struct irq_chip_generic gc[0]; + struct irq_chip_generic *gc[0]; }; /* Generic chip callback functions */ diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c index e212b26..3dbfe2e 100644 --- a/kernel/irq/generic-chip.c +++ b/kernel/irq/generic-chip.c @@ -247,6 +247,7 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, struct irq_chip_generic *gc; int numchips, sz, i; unsigned long flags; + void *p; if (d->gc) return -EBUSY; @@ -260,9 +261,9 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type); sz *= numchips; - sz += sizeof(*dgc); + sz += sizeof(*dgc) + numchips * sizeof(void *); - dgc = kzalloc(sz, GFP_KERNEL); + p = dgc = kzalloc(sz, GFP_KERNEL); if (!dgc) return -ENOMEM; dgc->irqs_per_chip = irqs_per_chip; @@ -270,17 +271,22 @@ int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip, dgc->irq_flags_to_set = set; dgc->irq_flags_to_clear = clr; dgc->gc_flags = gcflags; - gc = dgc->gc; + d->gc = dgc; - for (i = 0; i < numchips; i++, gc++) { + p += sizeof(*dgc) + numchips * sizeof(void *); + for (i = 0; i < numchips; i++) { + gc = (struct irq_chip_generic *)p; + dgc->gc[i] = gc; irq_init_generic_chip(gc, name, num_ct, i * irqs_per_chip, NULL, handler); gc->domain = d; + raw_spin_lock_irqsave(&gc_lock, flags); list_add_tail(&gc->list, &gc_list); raw_spin_unlock_irqrestore(&gc_lock, flags); + + p += sizeof(*gc) + num_ct * sizeof(struct irq_chip_type); } - d->gc = dgc; return 0; } EXPORT_SYMBOL_GPL(irq_alloc_domain_generic_chips); @@ -301,7 +307,7 @@ irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq) idx = hw_irq / dgc->irqs_per_chip; if (idx >= dgc->num_chips) return NULL; - return &dgc->gc[idx]; + return dgc->gc[idx]; } EXPORT_SYMBOL_GPL(irq_get_domain_generic_chip); @@ -331,7 +337,7 @@ static int irq_map_generic_chip(struct irq_domain *d, unsigned int virq, idx = hw_irq / dgc->irqs_per_chip; if (idx >= dgc->num_chips) return -EINVAL; - gc = &dgc->gc[idx]; + gc = dgc->gc[idx]; idx = hw_irq % dgc->irqs_per_chip; -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/