* [PATCH] char: misc: Use IS_ERR() for filp_open() return value
@ 2025-12-26 9:14 Alper Ak
2025-12-26 19:12 ` Thadeu Lima de Souza Cascardo
0 siblings, 1 reply; 4+ messages in thread
From: Alper Ak @ 2025-12-26 9:14 UTC (permalink / raw)
To: arnd, gregkh; +Cc: cascardo, linux-kernel, Alper Ak
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.
Fixes: 74d8361be344 ("char: misc: add test cases")
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
drivers/char/misc_minor_kunit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/misc_minor_kunit.c b/drivers/char/misc_minor_kunit.c
index 6fc8b05169c5..e930c78e1ef9 100644
--- a/drivers/char/misc_minor_kunit.c
+++ b/drivers/char/misc_minor_kunit.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] char: misc: Use IS_ERR() for filp_open() return value
2025-12-26 9:14 [PATCH] char: misc: Use IS_ERR() for filp_open() return value Alper Ak
@ 2025-12-26 19:12 ` Thadeu Lima de Souza Cascardo
2025-12-26 23:02 ` Alper Ak
0 siblings, 1 reply; 4+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2025-12-26 19:12 UTC (permalink / raw)
To: Alper Ak; +Cc: arnd, gregkh, linux-kernel
On Fri, Dec 26, 2025 at 12:14:51PM +0300, Alper Ak wrote:
> 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.
>
> Fixes: 74d8361be344 ("char: misc: add test cases")
> Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
> ---
> drivers/char/misc_minor_kunit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/misc_minor_kunit.c b/drivers/char/misc_minor_kunit.c
> index 6fc8b05169c5..e930c78e1ef9 100644
> --- a/drivers/char/misc_minor_kunit.c
> +++ b/drivers/char/misc_minor_kunit.c
> @@ -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);
> --
> 2.43.0
>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Also, if possible, please add the following, as this was previously
reported, and I forgot to fix it:
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202506132058.thWZHlrb-lkp@intel.com/
Thanks.
Cascardo.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] char: misc: Use IS_ERR() for filp_open() return value
2025-12-26 19:12 ` Thadeu Lima de Souza Cascardo
@ 2025-12-26 23:02 ` Alper Ak
2025-12-27 2:16 ` Thadeu Lima de Souza Cascardo
0 siblings, 1 reply; 4+ messages in thread
From: Alper Ak @ 2025-12-26 23:02 UTC (permalink / raw)
To: cascardo
Cc: alperyasinak1, arnd, gregkh, linux-kernel, kernel test robot,
Dan Carpenter
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.
Fixes: 74d8361be344 ("char: misc: add test cases")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202506132058.thWZHlrb-lkp@intel.com/
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
drivers/char/misc_minor_kunit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/misc_minor_kunit.c b/drivers/char/misc_minor_kunit.c
index 6fc8b05169c5..e930c78e1ef9 100644
--- a/drivers/char/misc_minor_kunit.c
+++ b/drivers/char/misc_minor_kunit.c
@@ -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);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] char: misc: Use IS_ERR() for filp_open() return value
2025-12-26 23:02 ` Alper Ak
@ 2025-12-27 2:16 ` Thadeu Lima de Souza Cascardo
0 siblings, 0 replies; 4+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2025-12-27 2:16 UTC (permalink / raw)
To: Alper Ak; +Cc: arnd, gregkh, linux-kernel, kernel test robot, Dan Carpenter
On Sat, Dec 27, 2025 at 02:02:48AM +0300, Alper Ak wrote:
> 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.
>
> Fixes: 74d8361be344 ("char: misc: add test cases")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202506132058.thWZHlrb-lkp@intel.com/
> Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
> ---
> drivers/char/misc_minor_kunit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/misc_minor_kunit.c b/drivers/char/misc_minor_kunit.c
> index 6fc8b05169c5..e930c78e1ef9 100644
> --- a/drivers/char/misc_minor_kunit.c
> +++ b/drivers/char/misc_minor_kunit.c
> @@ -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);
> --
> 2.43.0
>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-27 2:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-26 9:14 [PATCH] char: misc: Use IS_ERR() for filp_open() return value Alper Ak
2025-12-26 19:12 ` Thadeu Lima de Souza Cascardo
2025-12-26 23:02 ` Alper Ak
2025-12-27 2:16 ` Thadeu Lima de Souza Cascardo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox