]> git.itanic.dy.fi Git - linux-stable/commitdiff
kunit: device: Fix a NULL vs IS_ERR() check in init()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 10 Jan 2024 18:55:14 +0000 (21:55 +0300)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 22 Jan 2024 14:58:22 +0000 (07:58 -0700)
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>
Reviewed-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
lib/kunit/device.c

index f5371287b3750f0cefdc423748846b4257d8d14a..074c6dd2e36a7d9e8154a604db7c2a8e4f669921 100644 (file)
@@ -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)