arm: edma: check irq2ctlr() result
authorKulikov Vasiliy <segooon@gmail.com>
Sat, 17 Jul 2010 15:19:07 +0000 (19:19 +0400)
committerVaibhav Hiremath <hvaibhav@ti.com>
Mon, 23 Jan 2012 19:14:48 +0000 (00:44 +0530)
If irq2ctlr() fails return IRQ_NONE.
Also as it can fail make 'ctlr' signed.

The semantic patch that finds this problem (many false-positive results):
(http://coccinelle.lip6.fr/)

// <smpl>
@ r1 @
identifier f;
@@
int f(...) { ... }

@@
identifier r1.f;
type T;
unsigned T x;
@@

*x = f(...)
 ...
*x > 0

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
arch/arm/common/edma.c

index 1c352c89f66138e6d0fa537329690dc35a8ac1dd..64eca18e6a4b04ffa0c8d978b5cb171d7bef20de 100644 (file)
@@ -317,10 +317,12 @@ static int irq2ctlr(int irq)
 static irqreturn_t dma_irq_handler(int irq, void *data)
 {
        int i;
-       unsigned ctlr;
+       int ctlr;
        unsigned int cnt = 0;
 
        ctlr = irq2ctlr(irq);
+       if (ctlr < 0)
+               return IRQ_NONE;
 
        dev_dbg(data, "dma_irq_handler\n");
 
@@ -368,10 +370,12 @@ static irqreturn_t dma_irq_handler(int irq, void *data)
 static irqreturn_t dma_ccerr_handler(int irq, void *data)
 {
        int i;
-       unsigned ctlr;
+       int ctlr;
        unsigned int cnt = 0;
 
        ctlr = irq2ctlr(irq);
+       if (ctlr < 0)
+               return IRQ_NONE;
 
        dev_dbg(data, "dma_ccerr_handler\n");