Skip to content

Commit

Permalink
drm/vc4: tests: Use KUNIT_DEFINE_ACTION_WRAPPER
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Gow authored and Shuah Khan committed Dec 18, 2023
1 parent e847934 commit a08d4d6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/gpu/drm/vc4/tests/vc4_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit a08d4d6

Please sign in to comment.