Skip to content

Commit cc967be

Browse files
Julia LawallAl Viro
authored andcommitted
fs: Add missing mutex_unlock
Add a mutex_unlock missing on the error path. At other exists from the function that return an error flag, the mutex is unlocked, so do the same here. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression E1; @@ * mutex_lock(E1,...); <+... when != E1 if (...) { ... when != E1 * return ...; } ...+> * mutex_unlock(E1,...); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ea635c6 commit cc967be

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎fs/pipe.c‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,14 +1169,18 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
11691169

11701170
switch (cmd) {
11711171
case F_SETPIPE_SZ:
1172-
if (!capable(CAP_SYS_ADMIN) && arg > pipe_max_pages)
1173-
return -EINVAL;
1172+
if (!capable(CAP_SYS_ADMIN) && arg > pipe_max_pages) {
1173+
ret = -EINVAL;
1174+
goto out;
1175+
}
11741176
/*
11751177
* The pipe needs to be at least 2 pages large to
11761178
* guarantee POSIX behaviour.
11771179
*/
1178-
if (arg < 2)
1179-
return -EINVAL;
1180+
if (arg < 2) {
1181+
ret = -EINVAL;
1182+
goto out;
1183+
}
11801184
ret = pipe_set_size(pipe, arg);
11811185
break;
11821186
case F_GETPIPE_SZ:
@@ -1187,6 +1191,7 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
11871191
break;
11881192
}
11891193

1194+
out:
11901195
mutex_unlock(&pipe->inode->i_mutex);
11911196
return ret;
11921197
}

0 commit comments

Comments
 (0)