* [PATCH 4/12] drivers/gpio: Add missing unlock
@ 2010-03-29 15:34 ` Julia Lawall
0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-03-29 15:34 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
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>
---
drivers/gpio/timbgpio.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
index d4295fa..ae143dd 100644
--- a/drivers/gpio/timbgpio.c
+++ b/drivers/gpio/timbgpio.c
@@ -130,6 +130,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;
@@ -153,8 +154,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;
@@ -174,8 +177,9 @@ 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);
+out:
+ spin_unlock_irqrestore(&tgpio->lock, flags);
return 0;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/12] drivers/gpio: Add missing unlock
@ 2010-03-29 15:34 ` Julia Lawall
0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-03-29 15:34 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
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>
---
drivers/gpio/timbgpio.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
index d4295fa..ae143dd 100644
--- a/drivers/gpio/timbgpio.c
+++ b/drivers/gpio/timbgpio.c
@@ -130,6 +130,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;
@@ -153,8 +154,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;
@@ -174,8 +177,9 @@ 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);
+out:
+ spin_unlock_irqrestore(&tgpio->lock, flags);
return 0;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 4/12] drivers/gpio: Add missing unlock
2010-03-29 15:34 ` Julia Lawall
@ 2010-03-29 16:23 ` Julia Lawall
-1 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-03-29 16:23 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
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>
---
Corrected patch. Adjusted the return value.
drivers/gpio/timbgpio.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
index d4295fa..871608b 100644
--- a/drivers/gpio/timbgpio.c
+++ b/drivers/gpio/timbgpio.c
@@ -130,6 +130,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;
@@ -153,8 +154,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;
@@ -174,9 +177,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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 4/12] drivers/gpio: Add missing unlock
@ 2010-03-29 16:23 ` Julia Lawall
0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2010-03-29 16:23 UTC (permalink / raw)
To: linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
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>
---
Corrected patch. Adjusted the return value.
drivers/gpio/timbgpio.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
index d4295fa..871608b 100644
--- a/drivers/gpio/timbgpio.c
+++ b/drivers/gpio/timbgpio.c
@@ -130,6 +130,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;
@@ -153,8 +154,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;
@@ -174,9 +177,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)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-29 16:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-29 15:34 [PATCH 4/12] drivers/gpio: Add missing unlock Julia Lawall
2010-03-29 15:34 ` Julia Lawall
2010-03-29 16:23 ` Julia Lawall
2010-03-29 16:23 ` Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.