* [PATCH] mips: irq: Use DECLARE_BITMAP
@ 2015-05-20 12:44 Joe Perches
2015-05-21 13:14 ` Ralf Baechle
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2015-05-20 12:44 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, LKML, Gabor Juhos, Manuel Lauss, John Crispin
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
Signed-off-by: Joe Perches <joe@perches.com>
---
arch/mips/kernel/irq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index d2bfbc2..51f57d8 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -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)
{
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mips: irq: Use DECLARE_BITMAP
2015-05-20 12:44 [PATCH] mips: irq: Use DECLARE_BITMAP Joe Perches
@ 2015-05-21 13:14 ` Ralf Baechle
2015-05-21 16:10 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Ralf Baechle @ 2015-05-21 13:14 UTC (permalink / raw)
To: Joe Perches; +Cc: linux-mips, LKML, Gabor Juhos, Manuel Lauss, John Crispin
On Wed, May 20, 2015 at 05:44:54AM -0700, Joe Perches wrote:
> 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
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mips: irq: Use DECLARE_BITMAP
2015-05-21 13:14 ` Ralf Baechle
@ 2015-05-21 16:10 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2015-05-21 16:10 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips, LKML, Gabor Juhos, Manuel Lauss, John Crispin
On Thu, 2015-05-21 at 15:14 +0200, Ralf Baechle wrote:
> On Wed, May 20, 2015 at 05:44:54AM -0700, Joe Perches wrote:
>
> > 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
>
> 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!
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-21 16:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 12:44 [PATCH] mips: irq: Use DECLARE_BITMAP Joe Perches
2015-05-21 13:14 ` Ralf Baechle
2015-05-21 16:10 ` Joe Perches
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.