diff mbox series

drm/sched: add missing NULL check in drm_sched_get_cleanup_job v2

Message ID 20221004132831.134986-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series drm/sched: add missing NULL check in drm_sched_get_cleanup_job v2 | expand

Commit Message

Christian König Oct. 4, 2022, 1:28 p.m. UTC
Otherwise we would crash if the job is not resubmitted.

v2: fix second usage of s_fence->parent as well.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/scheduler/sched_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Steven Price Oct. 5, 2022, 8:53 a.m. UTC | #1
On 04/10/2022 14:28, Christian König wrote:
> Otherwise we would crash if the job is not resubmitted.
> 
> v2: fix second usage of s_fence->parent as well.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>  drivers/gpu/drm/scheduler/sched_main.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index ce86b03e8386..4cc59bae38dd 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -919,7 +919,8 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
>  	job = list_first_entry_or_null(&sched->pending_list,
>  				       struct drm_sched_job, list);
>  
> -	if (job && dma_fence_is_signaled(job->s_fence->parent)) {
> +	if (job && (!job->s_fence->parent ||
> +		    dma_fence_is_signaled(job->s_fence->parent))) {
>  		/* remove job from pending_list */
>  		list_del_init(&job->list);
>  
> @@ -929,7 +930,7 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
>  		next = list_first_entry_or_null(&sched->pending_list,
>  						typeof(*next), list);
>  
> -		if (next) {
> +		if (next && job->s_fence->parent) {
>  			next->s_fence->scheduled.timestamp =
>  				job->s_fence->parent->timestamp;
>  			/* start TO timer for next job */
diff mbox series

Patch

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index ce86b03e8386..4cc59bae38dd 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -919,7 +919,8 @@  drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
 	job = list_first_entry_or_null(&sched->pending_list,
 				       struct drm_sched_job, list);
 
-	if (job && dma_fence_is_signaled(job->s_fence->parent)) {
+	if (job && (!job->s_fence->parent ||
+		    dma_fence_is_signaled(job->s_fence->parent))) {
 		/* remove job from pending_list */
 		list_del_init(&job->list);
 
@@ -929,7 +930,7 @@  drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
 		next = list_first_entry_or_null(&sched->pending_list,
 						typeof(*next), list);
 
-		if (next) {
+		if (next && job->s_fence->parent) {
 			next->s_fence->scheduled.timestamp =
 				job->s_fence->parent->timestamp;
 			/* start TO timer for next job */