Commit 06a901c5621f85e07e00ac4816c7ca95620ee74a
Committed by
Paul Mackerras
1 parent
d1e8d50d5a
Exists in
master
and in
7 other branches
[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>
Showing 2 changed files with 4 additions and 19 deletions Side-by-side Diff
arch/powerpc/sysdev/mpic.c
| ... | ... | @@ -1331,6 +1331,9 @@ |
| 1331 | 1331 | unsigned long flags; |
| 1332 | 1332 | u32 reg; |
| 1333 | 1333 | |
| 1334 | + if (!mpic) | |
| 1335 | + return; | |
| 1336 | + | |
| 1334 | 1337 | spin_lock_irqsave(&mpic_lock, flags); |
| 1335 | 1338 | if (is_ipi) { |
| 1336 | 1339 | reg = mpic_ipi_read(src - mpic->ipi_vecs[0]) & |
| ... | ... | @@ -1344,23 +1347,6 @@ |
| 1344 | 1347 | reg | (pri << MPIC_VECPRI_PRIORITY_SHIFT)); |
| 1345 | 1348 | } |
| 1346 | 1349 | spin_unlock_irqrestore(&mpic_lock, flags); |
| 1347 | -} | |
| 1348 | - | |
| 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 | 1350 | } |
| 1365 | 1351 | |
| 1366 | 1352 | void mpic_setup_this_cpu(void) |
include/asm-powerpc/mpic.h
| ... | ... | @@ -428,12 +428,11 @@ |
| 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 | 432 | * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the |
| 433 | 433 | * IPI number is then the offset'ed (linux irq number mapped to the IPI) |
| 434 | 434 | */ |
| 435 | 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 | 437 | /* Setup a non-boot CPU */ |
| 439 | 438 | extern void mpic_setup_this_cpu(void); |