Skip to content

Commit

Permalink
kunit: Fix a NULL vs IS_ERR() bug
Browse files Browse the repository at this point in the history
The kunit_device_register() function doesn't return NULL, it returns
error pointers.  Change the KUNIT_ASSERT_NOT_NULL() to check for
ERR_OR_NULL().

Fixes: d03c720 ("kunit: Add APIs for managing devices")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Rae Moar <[email protected]>
Reviewed-by: David Gow <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
Dan Carpenter authored and shuahkh committed Jan 22, 2024
1 parent 6613476 commit ed1a72f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kunit/kunit-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ static void kunit_device_cleanup_test(struct kunit *test)
long action_was_run = 0;

test_device = kunit_device_register(test, "my_device");
KUNIT_ASSERT_NOT_NULL(test, test_device);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, test_device);

/* Add an action to verify cleanup. */
devm_add_action(test_device, test_dev_action, &action_was_run);
Expand Down

0 comments on commit ed1a72f

Please sign in to comment.