Skip to content

Commit 2801a5d

Browse files
Luo MengAlexei Starovoitov
Luo Meng
authored and
Alexei Starovoitov
committed
fail_function: Remove a redundant mutex unlock
Fix a mutex_unlock() issue where before copy_from_user() is not called mutex_locked. Fixes: 4b1a29a ("error-injection: Support fault injection framework") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Luo Meng <[email protected]> Signed-off-by: Masami Hiramatsu <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Masami Hiramatsu <[email protected]> Link: https://lore.kernel.org/bpf/160570737118.263807.8358435412898356284.stgit@devnote2
1 parent 14d6d86 commit 2801a5d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/fail_function.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
253253

254254
if (copy_from_user(buf, buffer, count)) {
255255
ret = -EFAULT;
256-
goto out;
256+
goto out_free;
257257
}
258258
buf[count] = '\0';
259259
sym = strstrip(buf);
@@ -307,8 +307,9 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
307307
ret = count;
308308
}
309309
out:
310-
kfree(buf);
311310
mutex_unlock(&fei_lock);
311+
out_free:
312+
kfree(buf);
312313
return ret;
313314
}
314315

0 commit comments

Comments
 (0)