All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: oushixiong1025@163.com
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RESEND] drm/sched: Create faux device for KUnit tests
Date: Thu, 03 Sep 2026 09:12:24 +0000	[thread overview]
Message-ID: <20260903091225.7831B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903090256.552317-1-oushixiong1025@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unmanaged 'faux_device' will be leaked if KUnit assertions fail, leaving a dangling sysfs device.
--

commit 55011cc21a49b0f659a9ade7e86087adb7a9989c
Author: Shixiong Ou <oushixiong@kylinos.cn>

drm/sched: Create faux device for KUnit tests

This commit updates the DRM scheduler KUnit tests to use a faux device
instead of passing a NULL device pointer to the scheduler initialization.
This prevents a NULL pointer dereference in the drm_sched_job trace event
which expects a valid device pointer.

> diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
> index 8e9ae7d980eb2..b6954224254e0 100644
> --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
> +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c
[ ... ]
> @@ -297,11 +301,20 @@ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout)
>  		.name		= "drm-mock-scheduler",
>  	};
>  	struct drm_mock_scheduler *sched;
> +	char name[64];
>  	int ret;
>  
>  	sched = kunit_kzalloc(test, sizeof(*sched), GFP_KERNEL);
>  	KUNIT_ASSERT_NOT_NULL(test, sched);
>  
> +	snprintf(name, sizeof(name), "drm-mock-scheduler-%d",
> +		 atomic_inc_return(&drm_mock_sched_instance));
> +
> +	sched->faux_dev = faux_device_create(name, NULL, NULL);
> +	KUNIT_ASSERT_NOT_NULL(test, sched->faux_dev);
> +
> +	args.dev = &sched->faux_dev->dev;
> +
>  	ret = drm_sched_init(&sched->base, &args);
>  	KUNIT_ASSERT_EQ(test, ret, 0);

[Severity: Medium]
If drm_sched_init() fails in drm_mock_sched_new(), will this KUNIT_ASSERT_EQ()
abort the test and leak the faux device allocated above?

Since faux_device_create() allocates and registers a device, but the faux_dev
is not directly managed by KUnit (for example, via kunit_add_action), an
assertion failure here would cause the test to exit immediately without calling
faux_device_destroy(). This could lead to a leak of the struct device and its
sysfs registration, leaving stale entries behind on test failures.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903090256.552317-1-oushixiong1025@163.com?part=1

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  9:02 [PATCH RESEND] drm/sched: Create faux device for KUnit tests oushixiong1025
2026-09-03  9:12 ` sashiko-bot [this message]
2026-09-03  9:33 ` Philipp Stanner
2026-09-03  9:36 ` Maxime Ripard
2026-09-03  9:53   ` Danilo Krummrich

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=20260903091225.7831B1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=oushixiong1025@163.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.