Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] Using KUNIT_ASSERT_EQ with unmanaged resources causes kernel memory 
leaks on test failure.
--

--- Patch [5]: [PATCH v2 05/13] drm/panic: Pass colors to draw_panic_dispatch() 
---
commit dfb1a50d1181cba2ccd93fe314ac428958a579a7
Author: Thomas Zimmermann <[email protected]>

drm/panic: Pass colors to draw_panic_dispatch()

This commit sets the panic-screen colors in a central location and passes
them to the individual drawing functions. In the test cases, it hardcodes
these colors to remove test dependencies on the exact config values.

> diff --git a/drivers/gpu/drm/tests/drm_panic_test.c 
> b/drivers/gpu/drm/tests/drm_panic_test.c
> index fdd77b0cc54c9..969a096ec840f 100644
> --- a/drivers/gpu/drm/tests/drm_panic_test.c
> +++ b/drivers/gpu/drm/tests/drm_panic_test.c
[ ... ]
> @@ -48,10 +41,27 @@ struct drm_test_mode {
>       .width = w, \
>       .height = h, \
>       .format = f, \
> -     .draw_screen = draw_panic_screen_##name, \
> +     .draw_screen = draw_panic_screen_ ## name ## _default, \

[Severity: Medium]
When params->draw_screen(sb) fails, does this cause the test to leak fb?

In drm_test_panic_screen_user_map(), the KUNIT_ASSERT_EQ() macro aborts the
test before vfree(fb) can execute:

drivers/gpu/drm/tests/drm_panic_test.c:drm_test_panic_screen_user_map() {
    ...
        fb = vmalloc(fb_size);
    ...
        ret = params->draw_screen(sb);
        KUNIT_ASSERT_EQ(test, ret, 0);
    ...
        vfree(fb);
}

Similarly, does drm_test_panic_screen_user_page() leak the allocated pages
when the test fails? An abort here skips the free_pages cleanup block:

drivers/gpu/drm/tests/drm_panic_test.c:drm_test_panic_screen_user_page() {
    ...
        ret = params->draw_screen(sb);
        KUNIT_ASSERT_EQ(test, ret, 0);
    ...
free_pages:
        for (p = 0; p < npages; p++)
                __free_page(pages[p]);
        kfree(pages);
}

>       .fname = #name, \
>       }, \

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

Reply via email to