aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/mpic.c
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2008-05-21 02:24:31 -0400
committerPaul Mackerras <paulus@samba.org>2008-05-23 02:15:37 -0400
commit06a901c5621f85e07e00ac4816c7ca95620ee74a (patch)
tree0f6a0d19d889e4209a41889ed868bc8af2a581eb /arch/powerpc/sysdev/mpic.c
parentd1e8d50d5a4bc7e40b119bf513804188ce2933d0 (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>
Diffstat (limited to 'arch/powerpc/sysdev/mpic.c')
-rw-r--r--arch/powerpc/sysdev/mpic.c20
1 files changed, 3 insertions, 17 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
1349unsigned 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
1366void mpic_setup_this_cpu(void) 1352void mpic_setup_this_cpu(void)
1367{ 1353{
1368#ifdef CONFIG_SMP 1354#ifdef CONFIG_SMP