The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [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

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