]> Git Repo - linux.git/commit - lib/test_lockup.c
lib/test_lockup.c: fix return value of test_lockup_init()
authorTiezhu Yang <[email protected]>
Wed, 12 Aug 2020 01:34:47 +0000 (18:34 -0700)
committerLinus Torvalds <[email protected]>
Wed, 12 Aug 2020 17:58:00 +0000 (10:58 -0700)
commit3adf3bae0d612357da516d39e1584f1547eb6e86
tree7b1df2a8ad78e4b7fbe2c199f50ae85bc921fa2d
parent63646bc9f95f7faf5345e54a59fd1ecdd4ba5316
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Cc: Kees Cook <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
lib/test_lockup.c
This page took 0.052915 seconds and 4 git commands to generate.