mips: irq: Use DECLARE_BITMAP
PATCH 1/1 mips: irq: Use DECLARE_BITMAP
Use the generic mechanism to declare a bitmap instead of unsigned long.
This could fix an overwrite defect of whatever follows irq_map.
Not all "#define NR_IRQS <value>" are a multiple of BITS_PER_LONG so using DECLARE_BITMAP allocates the proper number of longs required for the possible bits.
For instance:
arch/mips/include/asm/mach-ath79/irq.h:#define NR_IRQS 51
arch/mips/include/asm/mach-db1x00/irq.h:#define NR_IRQS 152 arch/mips/include/asm/mach-lantiq/falcon/irq.h:#define NR_IRQS 328
--- arch/mips/kernel/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/irq.c +1 -1
@@ -29,7 +29,7 @@int kgdb_early_setup;#endif -static unsigned long irq_map[NR_IRQS /BITS_PER_LONG ]; +static DECLARE_BITMAP(irq_map, NR_IRQS);int allocate_irqno (void ) {
Quoted 8 lines · Joe Perches
Use the generic mechanism to declare a bitmap instead of unsigned long.
This could fix an overwrite defect of whatever follows
irq_map.Not all "#define
NR_IRQS<value>" are a multiple ofBITS_PER_LONGso usingDECLARE_BITMAPallocates the proper number of longs required for the possible bits.
Quoted 5 lines
For instance:
arch/mips/include/asm/mach-ath79/irq.h:#define
NR_IRQS51
arch/mips/include/asm/mach-db1x00/irq.h:#defineNR_IRQS152 arch/mips/include/asm/mach-lantiq/falcon/irq.h:#defineNR_IRQS328
This only matters to user of the allocate_irqno() API and there is only on such platform, the IP27 which fortunately uses a NR_IRQS value that is a multiple of 64, so no impact.
Thanks anyway!
Ralf
Quoted 16 lines · Ralf Baechle
Quoted 8 lines · Joe Perches
Use the generic mechanism to declare a bitmap instead of unsigned long.
This could fix an overwrite defect of whatever follows
irq_map.Not all "#define
NR_IRQS<value>" are a multiple ofBITS_PER_LONGso usingDECLARE_BITMAPallocates the proper number of longs required for the possible bits.Quoted 5 lines
For instance:
arch/mips/include/asm/mach-ath79/irq.h:#define
NR_IRQS51
arch/mips/include/asm/mach-db1x00/irq.h:#defineNR_IRQS152 arch/mips/include/asm/mach-lantiq/falcon/irq.h:#defineNR_IRQS328
Quoted 5 lines
This only matters to user of the
allocate_irqno()API and there is only on such platform, the IP27 which fortunately uses aNR_IRQSvalue that is a multiple of 64, so no impact.Thanks anyway!
I think you should apply it anyway as it's an error-prone style.
There are 3 mechanisms used today in the kernel to declare bitmap arrays.
DECLARE_BITMAP(array, size) unsigned long array[BITS_TO_LONGS(size)] unsigned long array[size/BITS_PER_LONG]
The first 2 are fine, the last has this defect possible whenever size % BITS_PER_LONG != 0.
The series I sent converts all the uses of the the possibly defective style.
cheers, Joe