drm/scheduler: Set sched->thread to NULL on failure
authorSharat Masetty <smasetty@codeaurora.org>
Thu, 29 Nov 2018 10:05:19 +0000 (15:35 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 5 Dec 2018 22:56:16 +0000 (17:56 -0500)
In cases where the scheduler instance is used as a base object of another
driver object, it's not clear if the driver can call scheduler cleanup on the
fail path. So, Set the sched->thread to NULL, so that the driver can safely
call drm_sched_fini() during cleanup.

Signed-off-by: Sharat Masetty <smasetty@codeaurora.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/scheduler/sched_main.c

index 9d4cd196037a7abfda0268363460691ccc5b45fd..05b803d1248dc095b03d63dfdb8ce6d2870d359b 100644 (file)
@@ -612,7 +612,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
                   long timeout,
                   const char *name)
 {
-       int i;
+       int i, ret;
        sched->ops = ops;
        sched->hw_submission_limit = hw_submission;
        sched->name = name;
@@ -633,8 +633,10 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
        /* Each scheduler will run on a seperate kernel thread */
        sched->thread = kthread_run(drm_sched_main, sched, sched->name);
        if (IS_ERR(sched->thread)) {
+               ret = PTR_ERR(sched->thread);
+               sched->thread = NULL;
                DRM_ERROR("Failed to create scheduler for %s.\n", name);
-               return PTR_ERR(sched->thread);
+               return ret;
        }
 
        sched->ready = true;