<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">
<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);" class="elementToProof ContentPasted0">
There was a consensus to use memset instead of {0}. I remember making changes related to that previously.
<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 ContentPasted0">
<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 ContentPasted0">
Bhawan<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 ContentPasted0">
<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> Mahfooz, Hamza <Hamza.Mahfooz@amd.com><br>
<b>Sent:</b> October 27, 2023 11:53 AM<br>
<b>To:</b> Yuran Pereira <yuran.pereira@hotmail.com>; airlied@gmail.com <airlied@gmail.com><br>
<b>Cc:</b> Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Lakha, Bhawanpreet <Bhawanpreet.Lakha@amd.com>; Pan, Xinhui <Xinhui.Pan@amd.com>; Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; amd-gfx@lists.freedesktop.org
<amd-gfx@lists.freedesktop.org>; dri-devel@lists.freedesktop.org <dri-devel@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; linux-kernel-mentees@lists.linuxfoundation.org <linux-kernel-mentees@lists.linuxfoundation.org><br>
<b>Subject:</b> Re: [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 elementToProof">On 10/26/23 17:25, Yuran Pereira wrote:<br>
> 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>
<br>
I would prefer setting pr_config = {0};</div>
<div class="PlainText elementToProof"><br>
</div>
<div class="PlainText elementToProof">> 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>
Hamza<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>