• Tiezhu Yang's avatar
    lib/test_lockup.c: fix return value of test_lockup_init() · 3adf3bae
    Tiezhu Yang authored
    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: aecd42df ("lib/test_lockup.c: add parameters for locking generic vfs locks")
    Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Reviewed-by: default avatarGuenter 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.cnSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    3adf3bae
test_lockup.c 15.8 KB