char: misc: Use IS_ERR() for filp_open() return value
PATCH 1/1 char: misc: Use IS_ERR() for filp_open() return value
filp_open() never returns NULL, it returns either a valid pointer or an error pointer. Using IS_ERR_OR_NULL() is unnecessary. Additionally, if filp were NULL, PTR_ERR(NULL) would return 0, leading to a misleading error message.
--- drivers/char/misc_minor_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/misc_minor_kunit.c +1 -1
@@ -166,7 +166,7 @@ static void __init miscdev_test_can_open(struct kunit *test, struct miscdevice *KUNIT_FAIL (test,"failed to create node\n" ); filp =filp_open (devname,O_RDONLY ,0 ); -if (IS_ERR_OR_NULL (filp)) +if (IS_ERR (filp))KUNIT_FAIL (test,"failed to open misc device: %ld\n" ,PTR_ERR (filp));else fput (filp);
Signature · 1 line
2.43.0
Quoted 27 lines · Alper Ak
filp_open()never returns NULL, it returns either a valid pointer or an error pointer. UsingIS_ERR_OR_NULL()is unnecessary. Additionally, if filp were NULL,PTR_ERR(NULL)would return 0, leading to a misleading error message.Fixes 74d8361be344 ("char: misc: add test cases")Signed-off-by Alper Ak <[email protected]>--- drivers/char/misc_minor_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/misc_minor_kunit.c +1
-1@@ -166,7 +166,7 @@ static void __init miscdev_test_can_open(struct kunit *test, struct miscdevice *KUNIT_FAIL (test,"failed to create node\n" ); filp =filp_open (devname,O_RDONLY ,0 ); -if (IS_ERR_OR_NULL (filp)) +if (IS_ERR (filp))KUNIT_FAIL (test,"failed to open misc device: %ld\n" ,PTR_ERR (filp));else fput (filp);Signature · 1 line
2.43.0
Also, if possible, please add the following, as this was previously reported, and I forgot to fix it:
Thanks.
Cascardo.
PATCH 1/1 char: misc: Use IS_ERR() for filp_open() return value
filp_open() never returns NULL, it returns either a valid pointer or an error pointer. Using IS_ERR_OR_NULL() is unnecessary. Additionally, if filp were NULL, PTR_ERR(NULL) would return 0, leading to a misleading error message.
--- drivers/char/misc_minor_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/misc_minor_kunit.c +1 -1
@@ -166,7 +166,7 @@ static void __init miscdev_test_can_open(struct kunit *test, struct miscdevice *KUNIT_FAIL (test,"failed to create node\n" ); filp =filp_open (devname,O_RDONLY ,0 ); -if (IS_ERR_OR_NULL (filp)) +if (IS_ERR (filp))KUNIT_FAIL (test,"failed to open misc device: %ld\n" ,PTR_ERR (filp));else fput (filp);
Signature · 1 line
2.43.0
Quoted 30 lines · Alper Ak
filp_open()never returns NULL, it returns either a valid pointer or an error pointer. UsingIS_ERR_OR_NULL()is unnecessary. Additionally, if filp were NULL,PTR_ERR(NULL)would return 0, leading to a misleading error message.Fixes 74d8361be344 ("char: misc: add test cases")Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Alper Ak <[email protected]>--- drivers/char/misc_minor_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/misc_minor_kunit.c +1
-1@@ -166,7 +166,7 @@ static void __init miscdev_test_can_open(struct kunit *test, struct miscdevice *KUNIT_FAIL (test,"failed to create node\n" ); filp =filp_open (devname,O_RDONLY ,0 ); -if (IS_ERR_OR_NULL (filp)) +if (IS_ERR (filp))KUNIT_FAIL (test,"failed to open misc device: %ld\n" ,PTR_ERR (filp));else fput (filp);Signature · 1 line
2.43.0