summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kunit/test.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 0e9ff5d8fe84..46471bda351e 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -722,6 +722,9 @@ static inline bool kunit_kfree_match(struct kunit *test,
void kunit_kfree(struct kunit *test, const void *ptr)
{
+ if (!ptr)
+ return;
+
if (kunit_destroy_resource(test, kunit_kfree_match, (void *)ptr))
KUNIT_FAIL(test, "kunit_kfree: %px already freed or not allocated by kunit", ptr);
}