AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: wenjing.liu@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: [bug report] drm/amd/display: define link res and make it accessible to all link interfaces
Date: Mon, 10 Jan 2022 18:30:33 +0300	[thread overview]
Message-ID: <20220110153033.GA462@kili> (raw)

Hello Wenjing Liu,

The patch ef30f441f6ac: "drm/amd/display: define link res and make it
accessible to all link interfaces" from Nov 25, 2021, leads to the
following Smatch static checker warning:

    drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:4586 dc_link_set_drive_settings()
    warn: address of 'dc->current_state->res_ctx.pipe_ctx[i]' is non-NULL

    drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:4587 dc_link_set_drive_settings()
    error: we previously assumed 'pipe->stream' could be null (see line 4581)

drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c
    4568 void dc_link_set_drive_settings(struct dc *dc,
    4569                                 struct link_training_settings *lt_settings,
    4570                                 const struct dc_link *link)
    4571 {
    4572 
    4573         int i;
    4574         struct pipe_ctx *pipe = NULL;
    4575         const struct link_resource *link_res;
    4576 
    4577         link_res = dc_link_get_cur_link_res(link);
    4578 
    4579         for (i = 0; i < MAX_PIPES; i++) {
    4580                 pipe = &dc->current_state->res_ctx.pipe_ctx[i];
    4581                 if (pipe->stream && pipe->stream->link) {
                             ^^^^^^^^^^^^
This checks for "pipe->stream"


    4582                         if (pipe->stream->link == link)
    4583                                 break;
    4584                 }
    4585         }
    4586         if (pipe && link_res)

"pipe" can't possibly be NULL

--> 4587                 dc_link_dp_set_drive_settings(pipe->stream->link, link_res, lt_settings);

This dereferences "pipe->stream" without checking

    4588         else
    4589                 ASSERT_CRITICAL(false);
    4590 }

regards,
dan carpenter

                 reply	other threads:[~2022-01-10 15:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220110153033.GA462@kili \
    --to=dan.carpenter@oracle.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=wenjing.liu@amd.com \
    /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