Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] ocfs2: Release mutex in error handling code

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>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>

authored by

Julia Lawall and committed by
Mark Fasheh
c259ae52 961cecbe

+1 -1
+1 -1
fs/ocfs2/file.c
··· 1766 1766 out_rw_unlock: 1767 1767 ocfs2_rw_unlock(inode, 1); 1768 1768 1769 - mutex_unlock(&inode->i_mutex); 1770 1769 out: 1770 + mutex_unlock(&inode->i_mutex); 1771 1771 return ret; 1772 1772 } 1773 1773