AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Roman.Li@amd.com
Cc: amd-gfx@lists.freedesktop.org
Subject: [bug report] drm/amd/display: Add dcn3.01 support to DC (v2)
Date: Tue, 26 Jul 2022 18:19:11 +0300	[thread overview]
Message-ID: <YuAF72UERzrbibab@kili> (raw)

[ It's not clear to me why Smatch is complaining about 2 year old code
  but that seems like the buggy commit? ]

Hello Roman Li,

The patch 3a83e4e64bb1: "drm/amd/display: Add dcn3.01 support to DC
(v2)" from Sep 29, 2020, leads to the following Smatch static checker
warning:

	drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn301/vg_clk_mgr.c:539 find_dcfclk_for_voltage()
	error: buffer overflow 'clock_table->DcfClocks' 7 <= 7

drivers/gpu/drm/amd/amdgpu/../display/dc/clk_mgr/dcn301/vg_clk_mgr.c
    532 static unsigned int find_dcfclk_for_voltage(const struct vg_dpm_clocks *clock_table,
    533                 unsigned int voltage)
    534 {
    535         int i;
    536 
    537         for (i = 0; i < VG_NUM_SOC_VOLTAGE_LEVELS; i++) {
    538                 if (clock_table->SocVoltage[i] == voltage)
--> 539                         return clock_table->DcfClocks[i];
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^
The ->SocVoltage[] array has 8 elements but the ->DcfClocks[] array
only has 7 and the mismatch leads to an out of bounds.

    540         }
    541 
    542         ASSERT(0);
    543         return 0;
    544 }

regards,
dan carpenter

                 reply	other threads:[~2022-07-26 15:19 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=YuAF72UERzrbibab@kili \
    --to=dan.carpenter@oracle.com \
    --cc=Roman.Li@amd.com \
    --cc=amd-gfx@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