aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-04-06 14:34:48 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-04-07 08:38:02 -0700
commit2a481800caf78f4750cc673c8baed12b5d703ff6 (patch)
tree7ddbde66351fdf26c262fe8127a98704284e9456 /drivers/gpio
parentc70c036f04b7b74282477d6a51bbcc8bb8897e03 (diff)
drivers/gpio/timbgpio.c: add missing unlock
In an error handling case the lock is not unlocked. The return is converted to a goto, to share the unlock at the end of the function. A simplified version of the semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r exists@ expression E1; identifier f; @@ f (...) { <+... * spin_lock_irqsave (E1,...); ... when != E1 * return ...; ...+> } // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Cc: <richard.rojfors@pelagicore.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/timbgpio.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
index ac4d0f0ea02..ddd053108a1 100644
--- a/drivers/gpio/timbgpio.c
+++ b/drivers/gpio/timbgpio.c
@@ -131,6 +131,7 @@ static int timbgpio_irq_type(unsigned irq, unsigned trigger)
unsigned long flags;
u32 lvr, flr, bflr = 0;
u32 ver;
+ int ret = 0;
if (offset < 0 || offset > tgpio->gpio.ngpio)
return -EINVAL;
@@ -154,8 +155,10 @@ static int timbgpio_irq_type(unsigned irq, unsigned trigger)
}
if ((trigger & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
- if (ver < 3)
- return -EINVAL;
+ if (ver < 3) {
+ ret = -EINVAL;
+ goto out;
+ }
else {
flr |= 1 << offset;
bflr |= 1 << offset;
@@ -175,9 +178,10 @@ static int timbgpio_irq_type(unsigned irq, unsigned trigger)
iowrite32(bflr, tgpio->membase + TGPIO_BFLR);
iowrite32(1 << offset, tgpio->membase + TGPIO_ICR);
- spin_unlock_irqrestore(&tgpio->lock, flags);
- return 0;
+out:
+ spin_unlock_irqrestore(&tgpio->lock, flags);
+ return ret;
}
static void timbgpio_irq(unsigned int irq, struct irq_desc *desc)