Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fortify: test: Use 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>

authored by

davidgow@google.com and committed by
Shuah Khan
46ee8f68 d03c720e

+3 -2
+3 -2
lib/fortify_kunit.c
··· 15 15 */ 16 16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 17 17 18 + #include <kunit/device.h> 18 19 #include <kunit/test.h> 19 20 #include <linux/device.h> 20 21 #include <linux/slab.h> ··· 270 269 size_t len; \ 271 270 \ 272 271 /* Create dummy device for devm_kmalloc()-family tests. */ \ 273 - dev = root_device_register(dev_name); \ 272 + dev = kunit_device_register(test, dev_name); \ 274 273 KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev), \ 275 274 "Cannot register test device\n"); \ 276 275 \ ··· 304 303 checker(len, devm_kmemdup(dev, "Ohai", len, gfp), \ 305 304 devm_kfree(dev, p)); \ 306 305 \ 307 - device_unregister(dev); \ 306 + kunit_device_unregister(test, dev); \ 308 307 } while (0) 309 308 DEFINE_ALLOC_SIZE_TEST_PAIR(devm_kmalloc) 310 309