<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt;">Thanks,</span></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted1 ContentPasted3">
<span style="font-family: "Segoe UI", "Segoe UI Web (West European)", "Helvetica Neue", sans-serif; font-size: 11pt;">Reviewed-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com></span><br>
</div>
<div id="appendonsend"></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Yuran Pereira <yuran.pereira@hotmail.com><br>
<b>Sent:</b> October 26, 2023 5:25 PM<br>
<b>To:</b> airlied@gmail.com <airlied@gmail.com><br>
<b>Cc:</b> Yuran Pereira <yuran.pereira@hotmail.com>; Wentland, Harry <Harry.Wentland@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>;
 Pan, Xinhui <Xinhui.Pan@amd.com>; daniel@ffwll.ch <daniel@ffwll.ch>; Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>; linux-kernel@vger.kernel.org
 <linux-kernel@vger.kernel.org>; linux-kernel-mentees@lists.linuxfoundation.org <linux-kernel-mentees@lists.linuxfoundation.org><br>
<b>Subject:</b> [PATCH] drm/amdgpu: Fixes uninitialized variable usage in amdgpu_dm_setup_replay</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">Since `pr_config` is not initialized after its declaration, the<br>
following operations with `replay_enable_option` may be performed<br>
when `replay_enable_option` is holding junk values which could<br>
possibly lead to undefined behaviour<br>
<br>
```<br>
    ...<br>
    pr_config.replay_enable_option |= pr_enable_option_static_screen;<br>
    ...<br>
<br>
    if (!pr_config.replay_timing_sync_supported)<br>
        pr_config.replay_enable_option &= ~pr_enable_option_general_ui;<br>
    ...<br>
```<br>
<br>
This patch initializes `pr_config` after its declaration to ensure that<br>
it doesn't contain junk data, and prevent any undefined behaviour<br>
<br>
Addresses-Coverity-ID: 1544428 ("Uninitialized scalar variable")<br>
Fixes: dede1fea4460 ("drm/amd/display: Add Freesync Panel DM code")<br>
Signed-off-by: Yuran Pereira <yuran.pereira@hotmail.com><br>
---<br>
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c | 3 +++<br>
 1 file changed, 3 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c<br>
index 32d3086c4cb7..40526507f50b 100644<br>
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c<br>
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c<br>
@@ -23,6 +23,7 @@<br>
  *<br>
  */<br>
 <br>
+#include <linux/string.h><br>
 #include "amdgpu_dm_replay.h"<br>
 #include "dc.h"<br>
 #include "dm_helpers.h"<br>
@@ -74,6 +75,8 @@ bool amdgpu_dm_setup_replay(struct dc_link *link, struct amdgpu_dm_connector *ac<br>
         struct replay_config pr_config;<br>
         union replay_debug_flags *debug_flags = NULL;<br>
 <br>
+       memset(&pr_config, 0, sizeof(pr_config));<br>
+<br>
         // For eDP, if Replay is supported, return true to skip checks<br>
         if (link->replay_settings.config.replay_supported)<br>
                 return true;<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>