[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202312061306.98DA6D275D@keescook>
Date: Wed, 6 Dec 2023 13:07:27 -0800
From: Kees Cook <keescook@...omium.org>
To: davidgow@...gle.com
Cc: Rae Moar <rmoar@...gle.com>,
Brendan Higgins <brendan.higgins@...ux.dev>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Matti Vaittinen <mazziesaccount@...il.com>,
Stephen Boyd <sboyd@...nel.org>,
Shuah Khan <skhan@...uxfoundation.org>,
Jonathan Corbet <corbet@....net>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>,
Maxime Ripard <mripard@...nel.org>,
linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org, linux-sound@...r.kernel.org
Subject: Re: [PATCH 2/4] fortify: test: Use kunit_device
On Tue, Dec 05, 2023 at 03:31:34PM +0800, davidgow@...gle.com wrote:
> 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.
>
> Signed-off-by: David Gow <davidgow@...gle.com>
> ---
> lib/fortify_kunit.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c
> index c8c33cbaae9e..f7a1fce8849b 100644
> --- a/lib/fortify_kunit.c
> +++ b/lib/fortify_kunit.c
> @@ -16,6 +16,7 @@
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> #include <kunit/test.h>
> +#include <kunit/device.h>
> #include <linux/device.h>
> #include <linux/slab.h>
> #include <linux/string.h>
> @@ -269,7 +270,7 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc)
> size_t len; \
> \
> /* Create dummy device for devm_kmalloc()-family tests. */ \
> - dev = root_device_register(dev_name); \
> + dev = kunit_device_register(test, dev_name); \
> KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev), \
> "Cannot register test device\n"); \
> \
> @@ -303,7 +304,7 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc)
> checker(len, devm_kmemdup(dev, "Ohai", len, gfp), \
> devm_kfree(dev, p)); \
> \
> - device_unregister(dev); \
> + kunit_device_unregister(test, dev); \
> } while (0)
> DEFINE_ALLOC_SIZE_TEST_PAIR(devm_kmalloc)
Acked-by: Kees Cook <keescook@...omium.org>
(As an aside; shouldn't this get automatically cleaned up like other
kunit resources, though?)
--
Kees Cook
Powered by blists - more mailing lists