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

drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER

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>

authored by

David Gow and committed by
Shuah Khan
a08d4d62 e847934b

+3 -6
+3 -6
drivers/gpu/drm/vc4/tests/vc4_mock.c
··· 153 153 return 0; 154 154 } 155 155 156 - static void kunit_action_drm_dev_unregister(void *ptr) 157 - { 158 - struct drm_device *drm = ptr; 159 - 160 - drm_dev_unregister(drm); 161 - } 156 + KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_drm_dev_unregister, 157 + drm_dev_unregister, 158 + struct drm_device *); 162 159 163 160 static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5) 164 161 {