summaryrefslogtreecommitdiffstats
path: root/lib/test_lockup.c
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2020-08-11 18:34:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2020-08-12 10:58:00 -0700
commit3adf3bae0d612357da516d39e1584f1547eb6e86 (patch)
tree7b1df2a8ad78e4b7fbe2c199f50ae85bc921fa2d /lib/test_lockup.c
parent63646bc9f95f7faf5345e54a59fd1ecdd4ba5316 (diff)
downloadlinux-stable-3adf3bae0d612357da516d39e1584f1547eb6e86.tar.gz
linux-stable-3adf3bae0d612357da516d39e1584f1547eb6e86.tar.bz2
linux-stable-3adf3bae0d612357da516d39e1584f1547eb6e86.zip
lib/test_lockup.c: fix return value of test_lockup_init()
Since filp_open() returns an error pointer, we should use IS_ERR() to check the return value and then return PTR_ERR() if failed to get the actual return value instead of always -EINVAL. E.g. without this patch: [root@localhost loongson]# ls no_such_file ls: cannot access no_such_file: No such file or directory [root@localhost loongson]# modprobe test_lockup file_path=no_such_file lock_sb_umount time_secs=60 state=S modprobe: ERROR: could not insert 'test_lockup': Invalid argument [root@localhost loongson]# dmesg | tail -1 [ 126.100596] test_lockup: cannot find file_path With this patch: [root@localhost loongson]# ls no_such_file ls: cannot access no_such_file: No such file or directory [root@localhost loongson]# modprobe test_lockup file_path=no_such_file lock_sb_umount time_secs=60 state=S modprobe: ERROR: could not insert 'test_lockup': Unknown symbol in module, or unknown parameter (see dmesg) [root@localhost loongson]# dmesg | tail -1 [ 95.134362] test_lockup: failed to open no_such_file: -2 Fixes: aecd42df6d39 ("lib/test_lockup.c: add parameters for locking generic vfs locks") Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Cc: Kees Cook <keescook@chromium.org> Link: http://lkml.kernel.org/r/1595555407-29875-2-git-send-email-yangtiezhu@loongson.cn Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/test_lockup.c')
-rw-r--r--lib/test_lockup.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/test_lockup.c b/lib/test_lockup.c
index 0f81252837b9..f1a020bcc763 100644
--- a/lib/test_lockup.c
+++ b/lib/test_lockup.c
@@ -512,8 +512,8 @@ static int __init test_lockup_init(void)
if (test_file_path[0]) {
test_file = filp_open(test_file_path, O_RDONLY, 0);
if (IS_ERR(test_file)) {
- pr_err("cannot find file_path\n");
- return -EINVAL;
+ pr_err("failed to open %s: %ld\n", test_file_path, PTR_ERR(test_file));
+ return PTR_ERR(test_file);
}
test_inode = file_inode(test_file);
} else if (test_lock_inode ||