diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2008-05-21 02:24:31 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-05-23 02:15:37 -0400 |
commit | 06a901c5621f85e07e00ac4816c7ca95620ee74a (patch) | |
tree | 0f6a0d19d889e4209a41889ed868bc8af2a581eb | |
parent | d1e8d50d5a4bc7e40b119bf513804188ce2933d0 (diff) |
[POWERPC] mpic: Fix use of uninitialized variable
Compiling ppc64_defconfig with gcc 4.3 gives thes warnings:
arch/powerpc/sysdev/mpic.c: In function 'mpic_irq_get_priority':
arch/powerpc/sysdev/mpic.c:1351: warning: 'is_ipi' may be used uninitialized in this function
arch/powerpc/sysdev/mpic.c: In function 'mpic_irq_set_priority':
arch/powerpc/sysdev/mpic.c:1328: warning: 'is_ipi' may be used uninitialized in this function
It turns out that in the cases where is_ipi is uninitialized, another
variable (mpic) will be NULL and it is dereferenced. Protect against
this by returning if mpic is NULL in mpic_irq_set_priority, and removing
mpic_irq_get_priority completely as it has no in tree callers.
This has the nice side effect of making the warning go away.
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/sysdev/mpic.c | 20 | ||||
-rw-r--r-- | include/asm-powerpc/mpic.h | 3 |
2 files changed, 4 insertions, 19 deletions
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 8619f2a3f1f6..7680001676a6 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
@@ -1331,6 +1331,9 @@ void mpic_irq_set_priority(unsigned int irq, unsigned int pri) | |||
1331 | unsigned long flags; | 1331 | unsigned long flags; |
1332 | u32 reg; | 1332 | u32 reg; |
1333 | 1333 | ||
1334 | if (!mpic) | ||
1335 | return; | ||
1336 | |||
1334 | spin_lock_irqsave(&mpic_lock, flags); | 1337 | spin_lock_irqsave(&mpic_lock, flags); |
1335 | if (is_ipi) { | 1338 | if (is_ipi) { |
1336 | reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & | 1339 | reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & |
@@ -1346,23 +1349,6 @@ void mpic_irq_set_priority(unsigned int irq, unsigned int pri) | |||
1346 | spin_unlock_irqrestore(&mpic_lock, flags); | 1349 | spin_unlock_irqrestore(&mpic_lock, flags); |
1347 | } | 1350 | } |
1348 | 1351 | ||
1349 | unsigned int mpic_irq_get_priority(unsigned int irq) | ||
1350 | { | ||
1351 | unsigned int is_ipi; | ||
1352 | struct mpic *mpic = mpic_find(irq, &is_ipi); | ||
1353 | unsigned int src = mpic_irq_to_hw(irq); | ||
1354 | unsigned long flags; | ||
1355 | u32 reg; | ||
1356 | |||
1357 | spin_lock_irqsave(&mpic_lock, flags); | ||
1358 | if (is_ipi) | ||
1359 | reg = mpic_ipi_read(src = mpic->ipi_vecs[0]); | ||
1360 | else | ||
1361 | reg = mpic_irq_read(src, MPIC_INFO(IRQ_VECTOR_PRI)); | ||
1362 | spin_unlock_irqrestore(&mpic_lock, flags); | ||
1363 | return (reg & MPIC_VECPRI_PRIORITY_MASK) >> MPIC_VECPRI_PRIORITY_SHIFT; | ||
1364 | } | ||
1365 | |||
1366 | void mpic_setup_this_cpu(void) | 1352 | void mpic_setup_this_cpu(void) |
1367 | { | 1353 | { |
1368 | #ifdef CONFIG_SMP | 1354 | #ifdef CONFIG_SMP |
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h index 943c5a3fac8a..a4d0f876b427 100644 --- a/include/asm-powerpc/mpic.h +++ b/include/asm-powerpc/mpic.h | |||
@@ -428,12 +428,11 @@ extern void mpic_init(struct mpic *mpic); | |||
428 | */ | 428 | */ |
429 | 429 | ||
430 | 430 | ||
431 | /* Change/Read the priority of an interrupt. Default is 8 for irqs and | 431 | /* Change the priority of an interrupt. Default is 8 for irqs and |
432 | * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the | 432 | * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the |
433 | * IPI number is then the offset'ed (linux irq number mapped to the IPI) | 433 | * IPI number is then the offset'ed (linux irq number mapped to the IPI) |
434 | */ | 434 | */ |
435 | extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri); | 435 | extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri); |
436 | extern unsigned int mpic_irq_get_priority(unsigned int irq); | ||
437 | 436 | ||
438 | /* Setup a non-boot CPU */ | 437 | /* Setup a non-boot CPU */ |
439 | extern void mpic_setup_this_cpu(void); | 438 | extern void mpic_setup_this_cpu(void); |