genirq/generic_chip: Verify irqs_per_chip <= 32
Most (if not all) code here implicitly assumes that the maximum number of IRQs per chip will be 32, and thus uses 'u32' or 'unsigned long' for many tasks (for example "struct irq_data" declares its 'mask' field as 'u32', and "struct irq_chip_generic" declares its 'installed' field as 'unsigned long') However, there is no check to verify that irqs_per_chip is <= 32. Hence, calling irq_alloc_domain_generic_chips() with a bigger value will result in unexpected results. Provide a wrapper with a MAYBE_BUILD_BUG_ON(nrirqs >= 32) to catch such cases. [ tglx: Reduced changelog to the essential information ] Signed-off-by: Sebastian Frias <sf84@laposte.net> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: Mason <slash.tmp@free.fr> Cc: Jason Cooper <jason@lakedaemon.net> Link: http://lkml.kernel.org/r/57B31D94.5040701@laposte.net Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:

committed by
Thomas Gleixner

parent
0c228919e0
commit
f88eecfe2f
@@ -916,12 +916,20 @@ void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
|
||||
unsigned int clr, unsigned int set);
|
||||
|
||||
struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq);
|
||||
int irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
|
||||
int num_ct, const char *name,
|
||||
irq_flow_handler_t handler,
|
||||
unsigned int clr, unsigned int set,
|
||||
enum irq_gc_flags flags);
|
||||
|
||||
int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
|
||||
int num_ct, const char *name,
|
||||
irq_flow_handler_t handler,
|
||||
unsigned int clr, unsigned int set,
|
||||
enum irq_gc_flags flags);
|
||||
|
||||
#define irq_alloc_domain_generic_chips(d, irqs_per_chip, num_ct, name, \
|
||||
handler, clr, set, flags) \
|
||||
({ \
|
||||
MAYBE_BUILD_BUG_ON(irqs_per_chip > 32); \
|
||||
__irq_alloc_domain_generic_chips(d, irqs_per_chip, num_ct, name,\
|
||||
handler, clr, set, flags); \
|
||||
})
|
||||
|
||||
static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
|
||||
{
|
||||
|
Reference in New Issue
Block a user