Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org, Frank.Li@kernel.org,
	imx@lists.linux.dev, intel-gfx@lists.freedesktop.org,
	linux-hyperv@vger.kernel.org, intel-xe@lists.freedesktop.org,
	virtualization@lists.linux.dev, gary@garyguo.net,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>,
	wsa+renesas@sang-engineering.com, ojeda@kernel.org
Subject: Re: [PATCH v4 14/14] drm/panic: Compile KUnit tests as module
Date: Wed, 09 Sep 2026 09:37:27 +0000	[thread overview]
Message-ID: <20260909093728.4E1931F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909085826.64529-15-tzimmermann@suse.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The KUnit test exit function `drm_test_panic_exit()` fails to clear the global panic description, leaving a dangling pointer that can crash the panic handler.
--

commit 7eb0aee35aa7e3c110129d29f0c30be49ac71dab
Author: Thomas Zimmermann <tzimmermann@suse.de>

drm/panic: Compile KUnit tests as module

This commit fixes the panic-helper KUnit tests dependency and enables them to
be built as a module. It exports necessary interfaces if KUnit is enabled and
adds cleanup logic for the tests.

> diff --git a/drivers/gpu/drm/drm_panic_helper.c b/drivers/gpu/drm/drm_panic_helper.c
[ ... ]
> @@ -815,7 +820,7 @@ static int draw_panic_helper_dispatch(struct drm_scanout_buffer *sb,
>  	return ret;
>  }
>  
> -static void drm_panic_helper_set_description(const char *description)
> +VISIBLE_IF_KUNIT void drm_panic_helper_set_description(const char *description)
>  {
>  	u32 len;
>  
> @@ -830,6 +835,7 @@ static void drm_panic_helper_set_description(const char *description)
>  		desc_line->len = len;
>  	}
>  }
> +EXPORT_SYMBOL_IF_KUNIT(drm_panic_helper_set_description);
[ ... ]
> diff --git a/drivers/gpu/drm/tests/drm_panic_helper_test.c b/drivers/gpu/drm/tests/drm_panic_helper_test.c
[ ... ]
> @@ -86,6 +90,11 @@ static int drm_test_panic_init(struct kunit *test)
>  	return 0;
>  }
>  
> +static void drm_test_panic_exit(struct kunit *test)
> +{
> +	drm_panic_helper_set_description(NULL);
> +}

[Severity: High]
Does this leave a dangling pointer in the global panic_msg array when the test
module is unloaded?

Looking at drm_panic_helper_set_description() in drm_panic_helper.c, it
checks if the argument is valid before modifying the state:

    if (description) {
        struct drm_panic_line *desc_line = &panic_msg[panic_msg_lines - 1];
        desc_line->txt = description;
        ...
    }

When drm_test_panic_exit() calls drm_panic_helper_set_description(NULL) to
clear the state, the NULL argument is silently ignored. 

Since drm_test_panic_init() originally sets the description to a string
located in the test module's read-only data, the global panic_msg array will
retain a pointer to this memory even after the module is freed.

If a system panic occurs later, could the panic handler fault when trying to
dereference this stale pointer and fail to render the panic screen?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260909085826.64529-1-tzimmermann@suse.de?part=14

      reply	other threads:[~2026-09-09  9:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  8:55 [PATCH v4 00/14] drm/panic: Split into core and helpers Thomas Zimmermann
2026-09-09  8:55 ` [PATCH v4 01/14] drm/panic: Do not use un-escaped URL as format string Thomas Zimmermann
2026-09-09  9:09   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 02/14] drm/panic: Test address from kmap op for NULL Thomas Zimmermann
2026-09-09  9:15   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 03/14] drm/panic: Return -EINVAL if font is not available Thomas Zimmermann
2026-09-09  9:08   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 04/14] drm/panic: Return errno codes if panic output fails Thomas Zimmermann
2026-09-09  9:13   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 05/14] drm/panic: Pass colors to draw_panic_dispatch() Thomas Zimmermann
2026-09-09  9:13   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 06/14] drm/panic: Pass global module parameters to drm_panic_dispatch() Thomas Zimmermann
2026-09-09  9:22   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 07/14] drm/panic: Return from screen_user if display is too small Thomas Zimmermann
2026-09-09  9:18   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 08/14] drm/panic: Retry in dispatch function if panic output fails Thomas Zimmermann
2026-09-09  9:17   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 09/14] drm/panic: Split draw_panic_plane() Thomas Zimmermann
2026-09-09  9:20   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 10/14] drm/panic: Restrict to primary planes Thomas Zimmermann
2026-09-09  9:22   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 11/14] drm/panic: Display panic screen via per-plane callback Thomas Zimmermann
2026-09-09  9:29   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 12/14] drm/panic: Internalize panic locking in DRM core and helpers Thomas Zimmermann
2026-09-09  9:28   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 13/14] drm/panic: Move panic display code into helper library Thomas Zimmermann
2026-09-09  9:32   ` sashiko-bot
2026-09-09  8:55 ` [PATCH v4 14/14] drm/panic: Compile KUnit tests as module Thomas Zimmermann
2026-09-09  9:37   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260909093728.4E1931F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eperezma@redhat.com \
    --cc=gary@garyguo.net \
    --cc=imx@lists.linux.dev \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox