dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: christian.koenig@amd.com, Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] drm/scheduler: rework job destruction
Date: Wed, 22 May 2019 16:07:25 +0300	[thread overview]
Message-ID: <20190522130724.GA31989@mwanda> (raw)

Hello Christian König,

The patch 5918045c4ed4: "drm/scheduler: rework job destruction" from
Apr 18, 2019, leads to the following static checker warning:

	drivers/gpu/drm/scheduler/sched_main.c:297 drm_sched_job_timedout()
	error: potential NULL dereference 'job'.

drivers/gpu/drm/scheduler/sched_main.c
   279  static void drm_sched_job_timedout(struct work_struct *work)
   280  {
   281          struct drm_gpu_scheduler *sched;
   282          struct drm_sched_job *job;
   283          unsigned long flags;
   284  
   285          sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
   286          job = list_first_entry_or_null(&sched->ring_mirror_list,
   287                                         struct drm_sched_job, node);
   288  
   289          if (job)
                    ^^^
We assume that job can be NULL.

   290                  job->sched->ops->timedout_job(job);
   291  
   292          /*
   293           * Guilty job did complete and hence needs to be manually removed
   294           * See drm_sched_stop doc.
   295           */
   296          if (sched->free_guilty) {

Originally (last week) this check was "if (list_empty(&job->node))"
which is obviously problematic if job is NULL.  It's not clear to me
that this new check ensures that job is non-NULL either.

   297                  job->sched->ops->free_job(job);
                        ^^^^^
Dereference.

   298                  sched->free_guilty = false;
   299          }
   300  
   301          spin_lock_irqsave(&sched->job_list_lock, flags);
   302          drm_sched_start_timeout(sched);
   303          spin_unlock_irqrestore(&sched->job_list_lock, flags);
   304  }

regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2019-05-22 13:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 13:07 Dan Carpenter [this message]
2019-05-22 13:53 ` [bug report] drm/scheduler: rework job destruction Grodzovsky, Andrey

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=20190522130724.GA31989@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=andrey.grodzovsky@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).