lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 10 Jan 2024 16:09:55 -0500
From: Rae Moar <rmoar@...gle.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: "davidgow@...gle.com" <davidgow@...gle.com>, Brendan Higgins <brendan.higgins@...ux.dev>, 
	Shuah Khan <skhan@...uxfoundation.org>, Matti Vaittinen <mazziesaccount@...il.com>, 
	Maxime Ripard <mripard@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
	linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com, 
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] kunit: device: Fix a NULL vs IS_ERR() check in init()

On Wed, Jan 10, 2024 at 1:55 PM Dan Carpenter <dan.carpenter@...aroorg> 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@...aro.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@...gle.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@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/dd938a86-38d9-4d62-abd0-1df80395fbbd%40moroto.mountain.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ