]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER
authorDavid Gow <davidgow@google.com>
Tue, 28 Nov 2023 07:24:07 +0000 (15:24 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 18 Dec 2023 20:21:14 +0000 (13:21 -0700)
In order to pass functions to kunit_add_action(), they need to be of the
kunit_action_t type. While casting the function pointer can work, it
will break control-flow integrity.

vc4_mock already defines such a wrapper for drm_dev_unregister(), but it
involves less boilerplate to use the new macro, so replace the manual
implementation.

Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
drivers/gpu/drm/vc4/tests/vc4_mock.c

index 63ca46f4cb350551288d6f80e85cda1a223eb1d4..becb3dbaa548e247868c965ee08243b395ab30ba 100644 (file)
@@ -153,12 +153,9 @@ static int __build_mock(struct kunit *test, struct drm_device *drm,
        return 0;
 }
 
-static void kunit_action_drm_dev_unregister(void *ptr)
-{
-       struct drm_device *drm = ptr;
-
-       drm_dev_unregister(drm);
-}
+KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_drm_dev_unregister,
+                           drm_dev_unregister,
+                           struct drm_device *);
 
 static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
 {