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
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.