[PATCH 2/2] drm/sched: Set mock device in KUnit test scheduler
[email protected] Tue, 4 Aug 2026 18:09:56 +0800
| Newsgroups | gmane.linux.kernel,gmane.comp.video.dri.devel |
|---|---|
| Message-ID | <[email protected]> |
From: Shixiong Ou <[email protected]> The DRM scheduler KUnit tests do not set the dev field in drm_sched_init_args, leaving sched->dev as NULL. This causes a NULL pointer dereference when the drm_sched_job trace event fires during test execution, as dev_name(NULL) is called. Provide a static mock device with init_name set so that trace events and other code paths that reference sched->dev work correctly during testing. Signed-off-by: Shixiong Ou <[email protected]> --- drivers/gpu/drm/scheduler/tests/mock_scheduler.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c index 14403a762335..d14bcb69e318 100644 --- a/drivers/gpu/drm/scheduler/tests/mock_scheduler.c +++ b/drivers/gpu/drm/scheduler/tests/mock_scheduler.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2025 Valve Corporation */ +#include <linux/device.h> + #include "sched_tests.h" /* @@ -288,12 +290,16 @@ static const struct drm_sched_backend_ops drm_mock_scheduler_ops = { */ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout) { + static struct device mock_dev = { + .init_name = "drm-mock-device", + }; struct drm_sched_init_args args = { .ops = &drm_mock_scheduler_ops, .credit_limit = U32_MAX, .hang_limit = 1, .timeout = timeout, .name = "drm-mock-scheduler", + .dev = &mock_dev, }; struct drm_mock_scheduler *sched; int ret; -- 2.25.1 No virus found Checked by Hillstone Network AntiVirus