summaryrefslogtreecommitdiffstats
path: root/lib/overflow_kunit.c
diff options
context:
space:
mode:
authordavidgow@google.com <davidgow@google.com>2023-12-15 08:39:10 +0100
committerShuah Khan <skhan@linuxfoundation.org>2023-12-18 21:28:08 +0100
commit837018388e18bd740fb4f4371858f3e3a477fab8 (patch)
tree066641181260f5a65caf24cccea08cb133214672 /lib/overflow_kunit.c
parentfortify: test: Use kunit_device (diff)
downloadlinux-837018388e18bd740fb4f4371858f3e3a477fab8.tar.xz
linux-837018388e18bd740fb4f4371858f3e3a477fab8.zip
overflow: Replace fake root_device with kunit_device
Using struct root_device to create fake devices for tests is something of a hack. The new struct kunit_device is meant for this purpose, so use it instead. Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/overflow_kunit.c')
-rw-r--r--lib/overflow_kunit.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c
index 34db0b3aa502..c527f6b75789 100644
--- a/lib/overflow_kunit.c
+++ b/lib/overflow_kunit.c
@@ -6,6 +6,7 @@
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <kunit/device.h>
#include <kunit/test.h>
#include <linux/device.h>
#include <linux/kernel.h>
@@ -618,7 +619,7 @@ static void overflow_allocation_test(struct kunit *test)
} while (0)
/* Create dummy device for devm_kmalloc()-family tests. */
- dev = root_device_register(device_name);
+ dev = kunit_device_register(test, device_name);
KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev),
"Cannot register test device\n");
@@ -634,8 +635,6 @@ static void overflow_allocation_test(struct kunit *test)
check_allocation_overflow(devm_kmalloc);
check_allocation_overflow(devm_kzalloc);
- device_unregister(dev);
-
kunit_info(test, "%d allocation overflow tests finished\n", count);
#undef check_allocation_overflow
}