Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/amd/display: CFI violation and unchecked kunit_add_action()
  in dm_kunit_alloc_dc()
--

commit 3e7024f14775977bb5d35f97fcb673f3cd943908
Author: Dave Airlie <[email protected]>

drm/amd/display: Migrate amdgpu_dm KUnit tests off struct dc internals

This commit adds a KUnit test double API for struct dc and converts the
amdgpu_dm KUnit tests to use it instead of accessing struct dc fields
directly.

> diff --git 
> a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
> index f844b644bb776..9954cbab65416 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_kunit_helpers.c
> @@ -47,18 +48,29 @@ struct dc_link *dm_kunit_alloc_link(struct kunit *test)
>  }
>  EXPORT_SYMBOL(dm_kunit_alloc_link);
>  
> +struct dc *dm_kunit_alloc_dc(struct kunit *test)
> +{
> +     struct dc *dc;
> +
> +     dc = dc_test_create();
> +     KUNIT_ASSERT_NOT_NULL(test, dc);
> +     kunit_add_action(test, (kunit_action_t *)dc_test_destroy, dc);

[Severity: Low]
Does casting dc_test_destroy() (which takes struct dc *) to kunit_action_t *
(void (*)(void *)) trigger a KCFI failure on test teardown when built with
CONFIG_CFI_CLANG?  Also, kunit_add_action() can fail and leak dc if its
return value is not checked, whereas KUNIT_DEFINE_ACTION_WRAPPER() with
kunit_add_action_or_reset() avoids both issues.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=12

Reply via email to