linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6/7] drivers/video: Release mutex in error handling code
@ 2008-07-21  7:58 Julia Lawall
  2008-07-22  4:19 ` [Linux-fbdev-devel] " Krzysztof Helt
  2008-07-22  8:34 ` Ondrej Zajicek
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2008-07-21  7:58 UTC (permalink / raw)
  To: adaplas, linux-fbdev-devel, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

The mutex is released on a successful return, so it would seem that it
should be released on an error return as well.

The semantic patch finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression l;
@@

mutex_lock(l);
... when != mutex_unlock(l)
    when any
    when strict
(
if (...) { ... when != mutex_unlock(l)
+   mutex_unlock(l);
    return ...;
}
|
mutex_unlock(l);
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/video/arkfb.c    |    9 +++------
 drivers/video/vt8623fb.c |    9 +++------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff -u -p a/drivers/video/arkfb.c b/drivers/video/arkfb.c
--- a/drivers/video/arkfb.c
+++ b/drivers/video/arkfb.c
@@ -1126,11 +1126,8 @@ static int ark_pci_resume (struct pci_de
 	acquire_console_sem();
 	mutex_lock(&(par->open_lock));
 
-	if (par->ref_count == 0) {
-		mutex_unlock(&(par->open_lock));
-		release_console_sem();
-		return 0;
-	}
+	if (par->ref_count == 0)
+		goto fail;
 
 	pci_set_power_state(dev, PCI_D0);
 	pci_restore_state(dev);
@@ -1143,8 +1140,8 @@ static int ark_pci_resume (struct pci_de
 	arkfb_set_par(info);
 	fb_set_suspend(info, 0);
 
-	mutex_unlock(&(par->open_lock));
 fail:
+	mutex_unlock(&(par->open_lock));
 	release_console_sem();
 	return 0;
 }
diff -u -p a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -853,11 +853,8 @@ static int vt8623_pci_resume(struct pci_
 	acquire_console_sem();
 	mutex_lock(&(par->open_lock));
 
-	if (par->ref_count == 0) {
-		mutex_unlock(&(par->open_lock));
-		release_console_sem();
-		return 0;
-	}
+	if (par->ref_count == 0)
+		goto fail;
 
 	pci_set_power_state(dev, PCI_D0);
 	pci_restore_state(dev);
@@ -870,8 +867,8 @@ static int vt8623_pci_resume(struct pci_
 	vt8623fb_set_par(info);
 	fb_set_suspend(info, 0);
 
-	mutex_unlock(&(par->open_lock));
 fail:
+	mutex_unlock(&(par->open_lock));
 	release_console_sem();
 
 	return 0;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-fbdev-devel] [PATCH 6/7] drivers/video: Release mutex in error handling code
  2008-07-21  7:58 [PATCH 6/7] drivers/video: Release mutex in error handling code Julia Lawall
@ 2008-07-22  4:19 ` Krzysztof Helt
  2008-07-22  8:34 ` Ondrej Zajicek
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Helt @ 2008-07-22  4:19 UTC (permalink / raw)
  To: Julia Lawall; +Cc: adaplas, linux-fbdev-devel, linux-kernel, kernel-janitors

On Mon, 21 Jul 2008 09:58:55 +0200 (CEST)
Julia Lawall <julia@diku.dk> wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> The mutex is released on a successful return, so it would seem that it
> should be released on an error return as well.
> 
> The semantic patch finds this problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
> 
> // <smpl>
> @@
> expression l;
> @@
> 
> mutex_lock(l);
> ... when != mutex_unlock(l)
>     when any
>     when strict
> (
> if (...) { ... when != mutex_unlock(l)
> +   mutex_unlock(l);
>     return ...;
> }
> |
> mutex_unlock(l);
> )
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---

Acked-by: Krzysztof Helt <krzysztof.h1@wp.pl>

----------------------------------------------------------------------
Partyjka w Chinczyka?
Graj >>> http://link.interia.pl/f1e67


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-fbdev-devel] [PATCH 6/7] drivers/video: Release mutex in error handling code
  2008-07-21  7:58 [PATCH 6/7] drivers/video: Release mutex in error handling code Julia Lawall
  2008-07-22  4:19 ` [Linux-fbdev-devel] " Krzysztof Helt
@ 2008-07-22  8:34 ` Ondrej Zajicek
  1 sibling, 0 replies; 3+ messages in thread
From: Ondrej Zajicek @ 2008-07-22  8:34 UTC (permalink / raw)
  To: Julia Lawall; +Cc: adaplas, linux-fbdev-devel, linux-kernel, kernel-janitors

On Mon, Jul 21, 2008 at 09:58:55AM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> The mutex is released on a successful return, so it would seem that it
> should be released on an error return as well.
... 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Acked-by: Ondrej Zajicek <santiago@crfreenet.org>

-- 
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santiago@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-22  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-21  7:58 [PATCH 6/7] drivers/video: Release mutex in error handling code Julia Lawall
2008-07-22  4:19 ` [Linux-fbdev-devel] " Krzysztof Helt
2008-07-22  8:34 ` Ondrej Zajicek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).