* [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init()
@ 2024-01-10 18:55 Dan Carpenter
2024-01-10 21:09 ` Rae Moar
2024-01-11 23:42 ` David Gow
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-01-10 18:55 UTC (permalink / raw)
To: davidgow
Cc: Brendan Higgins, Shuah Khan, Matti Vaittinen, Maxime Ripard,
Greg Kroah-Hartman, linux-kselftest, kunit-dev, linux-kernel,
kernel-janitors
The root_device_register() function does not return NULL, it returns
error pointers. Fix the check to match.
Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
lib/kunit/device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/kunit/device.c b/lib/kunit/device.c
index f5371287b375..074c6dd2e36a 100644
--- a/lib/kunit/device.c
+++ b/lib/kunit/device.c
@@ -45,8 +45,8 @@ int kunit_bus_init(void)
int error;
kunit_bus_device = root_device_register("kunit");
- if (!kunit_bus_device)
- return -ENOMEM;
+ if (IS_ERR(kunit_bus_device))
+ return PTR_ERR(kunit_bus_device);
error = bus_register(&kunit_bus_type);
if (error)
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init()
2024-01-10 18:55 [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init() Dan Carpenter
@ 2024-01-10 21:09 ` Rae Moar
2024-01-11 23:42 ` David Gow
1 sibling, 0 replies; 3+ messages in thread
From: Rae Moar @ 2024-01-10 21:09 UTC (permalink / raw)
To: Dan Carpenter
Cc: davidgow, Brendan Higgins, Shuah Khan, Matti Vaittinen,
Maxime Ripard, Greg Kroah-Hartman, linux-kselftest, kunit-dev,
linux-kernel, kernel-janitors
On Wed, Jan 10, 2024 at 1:55 PM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The root_device_register() function does not return NULL, it returns
> error pointers. Fix the check to match.
>
> Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
This change looks good to me! We could check for IS_ERR_OR_NULL
instead but this change is more correct and is also how others check
root_device_register().
Reviewed-by: Rae Moar <rmoar@google.com>
Thanks!
Rae
> ---
> lib/kunit/device.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/kunit/device.c b/lib/kunit/device.c
> index f5371287b375..074c6dd2e36a 100644
> --- a/lib/kunit/device.c
> +++ b/lib/kunit/device.c
> @@ -45,8 +45,8 @@ int kunit_bus_init(void)
> int error;
>
> kunit_bus_device = root_device_register("kunit");
> - if (!kunit_bus_device)
> - return -ENOMEM;
> + if (IS_ERR(kunit_bus_device))
> + return PTR_ERR(kunit_bus_device);
>
> error = bus_register(&kunit_bus_type);
> if (error)
> --
> 2.43.0
>
> --
> You received this message because you are subscribed to the Google Groups "KUnit Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/dd938a86-38d9-4d62-abd0-1df80395fbbd%40moroto.mountain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init()
2024-01-10 18:55 [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init() Dan Carpenter
2024-01-10 21:09 ` Rae Moar
@ 2024-01-11 23:42 ` David Gow
1 sibling, 0 replies; 3+ messages in thread
From: David Gow @ 2024-01-11 23:42 UTC (permalink / raw)
To: Dan Carpenter
Cc: Brendan Higgins, Shuah Khan, Matti Vaittinen, Maxime Ripard,
Greg Kroah-Hartman, linux-kselftest, kunit-dev, linux-kernel,
kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 414 bytes --]
On Thu, 11 Jan 2024 at 02:55, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The root_device_register() function does not return NULL, it returns
> error pointers. Fix the check to match.
>
> Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
Thanks for catching this.
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4014 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-11 23:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 18:55 [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init() Dan Carpenter
2024-01-10 21:09 ` Rae Moar
2024-01-11 23:42 ` David Gow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®