Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2830672rdh; Mon, 30 Oct 2023 08:52:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdkFLQS6zsBTJpO0ZA/kW+yeWphSai1R8HN+8X0HdRqwRVh8Zvon0vwDWr0o58Ay2zJNUt X-Received: by 2002:a17:902:ea12:b0:1cc:5920:1d2a with SMTP id s18-20020a170902ea1200b001cc59201d2amr1716705plg.13.1698681162085; Mon, 30 Oct 2023 08:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698681162; cv=none; d=google.com; s=arc-20160816; b=aWF+9koS8ghKM42ciYlBb2sjzT6whI7bgb04o9RkOtmRZ1VCoUtkIZYfanXPGBfSxS zroDV3Hk0S5ZYDx70Zvp0M1COtzUYray810tsZoJCRpDrTWEUvq1D/7SCoddk1jkSiXb 6so+aED84PGdf6z0T7NIsnJ6UgfUxM3Rli2yBHxZCISz+nTe5Dl3AwrDWY7GjMFfVC56 Wrs7bUXqApw7e6vf/k1G/qpYyciMde4+tekf9eH86M631x+0wPRcatWYj5ZcyEhEUyUn +CoqqpQIeOUCnjiGmenrsnl71wxpr5MTPRL/62OlC1emMXyGeCndNmXsNl9mjjfv08/k FDYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=qcBEi1lBI38DN/iPYBUEKFD33e1P8VGGwEZLkT86i0o=; fh=bqgQHTQ2PU6ljmBLeO837SEPWQ51UBRoCUqF0hAmiyw=; b=fzKD7eOdrR2B1vH/btGRGqnoLBD429vFyyVpTCv4N6xjjIkTiFyTCAVVjyB4k6JoXI JgFIP5N8xaZ9hFLNoeIG94gmLHH5m+CPrCB7tuI5ylgbPVPunaA1qMVwbkbxsl6aA3Y4 SGet1sROPyDeJ8bpAM+9z9alz6Nl55knRZqXuo4O8JCJB9c4Ee5QN+6eqEzUM3d6jqeL JsWOIngMXMZc62EVJOFF9CUcGxpIVCX2FHftd4qpF3GdGtKuqn9s+U+SHNeo81u1XGC9 AXygQAt/yucpOIq31y+g/DduPC7DNREy9hRBcdWQV4EQicMQH7oNViVLFbVH5VxePRJQ TWrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OnwFDxQn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z6-20020a170903018600b001c7218c4db8si3153946plg.119.2023.10.30.08.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 08:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OnwFDxQn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4B1558030988; Mon, 30 Oct 2023 08:52:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233600AbjJ3Pwg (ORCPT + 99 others); Mon, 30 Oct 2023 11:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbjJ3Pwe (ORCPT ); Mon, 30 Oct 2023 11:52:34 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E80C5 for ; Mon, 30 Oct 2023 08:52:30 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-538e8eca9c1so7464389a12.3 for ; Mon, 30 Oct 2023 08:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698681149; x=1699285949; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=qcBEi1lBI38DN/iPYBUEKFD33e1P8VGGwEZLkT86i0o=; b=OnwFDxQn/S7Fb/dcQZG8ZAoM2RjKGNeGszz31t93ziMlKf7+UpvgTE43IMFiwwE7nS o7rM3LpFn4aboSrd98R6sssEkpXUnqEr7NcuLdsz/p+40XofJSrpLgN58eTablLyLKQC 9LJVgJOl1IPeo3alcuKVN/mTlr8is8xwS+mIF+bc3HObnznyVgEDDyI3MY5+Y10yQfaz iybeQcbfilGQ7NJcMCns1zSZv4ZzTi5GI8a4T29enAqldkIThsUtIOSQ/XEO/WF+n+Jb 9hd5VgwRIWMJGnj8JaWCjkBXeLK6GmUFnQz4xmcKAwADuwu5hqFAKBdMXnYLc98JdhV0 GPew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698681149; x=1699285949; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qcBEi1lBI38DN/iPYBUEKFD33e1P8VGGwEZLkT86i0o=; b=nT7ePtniW7HbNfeaWa4ed4JK+ZwFu+PPIUYBvofdfWOtd/IfMRh8Ymys5RtB3tJrv7 /9MBL/k1M2veJMpkhHzdOqUlutOc4EdRT3VT2rQ31lsvfaLKPzV5Pfi7m5cHzGdy8gYy v5ZRJ9B8AVRF0nh/X6Buwc7bx42emJ66I+IDmY6r/js1Fj+VVKjAE++/mspQRTkRr271 SM7PriG8FD6OCsPX7ob8OO5456RtRl6iApsJJsdXkuH8owZOdxrPeayvpAuNlj8S6rbQ YsbL+CqBNDfi8yoWn/7OfqH1k2+cqKvVCfRlWORQX3c4/rbpz3TPEIFLo3fnek0eBatc 8OXA== X-Gm-Message-State: AOJu0Yzm/LpObfMZJkLhNueCzb4OA0aUwt6aJoTk2yeuA9jouSlGNs0u 8Zvaqw9xkHEOshk1CYo27sk= X-Received: by 2002:a17:906:80da:b0:9d3:ccd1:a922 with SMTP id a26-20020a17090680da00b009d3ccd1a922mr2329078ejx.58.1698681149064; Mon, 30 Oct 2023 08:52:29 -0700 (PDT) Received: from [192.168.178.25] ([134.19.60.47]) by smtp.gmail.com with ESMTPSA id lo10-20020a170906fa0a00b00993a37aebc5sm6100891ejb.50.2023.10.30.08.52.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Oct 2023 08:52:28 -0700 (PDT) Message-ID: <403a0750-361e-4218-8c83-a085966349e4@gmail.com> Date: Mon, 30 Oct 2023 16:52:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/amdgpu: Fixes uninitialized variable usage in amdgpu_dm_setup_replay Content-Language: en-US To: Yuran Pereira , Hamza Mahfooz Cc: "Li, Sun peng (Leo)" , "Lakha, Bhawanpreet" , "Pan, Xinhui" , "Siqueira, Rodrigo" , "linux-kernel@vger.kernel.org" , "amd-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "Deucher, Alexander" , "airlied@gmail.com" , "Koenig, Christian" , "linux-kernel-mentees@lists.linuxfoundation.org" References: <39ab34ec-209d-4176-b271-1a02e2976497@amd.com> From: =?UTF-8?Q?Christian_K=C3=B6nig?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 30 Oct 2023 08:52:40 -0700 (PDT) Am 28.10.23 um 02:48 schrieb Yuran Pereira: > Hello, > On Fri, Oct 27, 2023 at 11:57:45AM -0400, Hamza Mahfooz wrote: >> On 10/27/23 11:55, Lakha, Bhawanpreet wrote: >>> [AMD Official Use Only - General] >>> >>> >>> >>> There was a consensus to use memset instead of {0}. I remember making >>> changes related to that previously. >> Hm, seems like it's used rather consistently in the DM and in DC >> though. >> > Have you decided which one should be used? > > Should I submit a v2 patch using {0} instead of memset? The problem is that {0} doesn't initialize padding fields in structures. So what can happen are problems like leaking bytes to userspace or getting unstable hash keys etc... So I think memset() is usually preferred and that not only counts for Linux. Regards, Christian. > > > Yuran Pereira >>> Bhawan >>> >>> ------------------------------------------------------------------------ >>> *From:* Mahfooz, Hamza >>> *Sent:* October 27, 2023 11:53 AM >>> *To:* Yuran Pereira ; airlied@gmail.com >>> >>> *Cc:* Li, Sun peng (Leo) ; Lakha, Bhawanpreet >>> ; Pan, Xinhui ; Siqueira, >>> Rodrigo ; linux-kernel@vger.kernel.org >>> ; amd-gfx@lists.freedesktop.org >>> ; dri-devel@lists.freedesktop.org >>> ; Deucher, Alexander >>> ; Koenig, Christian >>> ; >>> linux-kernel-mentees@lists.linuxfoundation.org >>> >>> *Subject:* Re: [PATCH] drm/amdgpu: Fixes uninitialized variable usage in >>> amdgpu_dm_setup_replay >>> On 10/26/23 17:25, Yuran Pereira wrote: >>>> Since `pr_config` is not initialized after its declaration, the >>>> following operations with `replay_enable_option` may be performed >>>> when `replay_enable_option` is holding junk values which could >>>> possibly lead to undefined behaviour >>>> >>>> ``` >>>>       ... >>>>       pr_config.replay_enable_option |= pr_enable_option_static_screen; >>>>       ... >>>> >>>>       if (!pr_config.replay_timing_sync_supported) >>>>           pr_config.replay_enable_option &= ~pr_enable_option_general_ui; >>>>       ... >>>> ``` >>>> >>>> This patch initializes `pr_config` after its declaration to ensure that >>>> it doesn't contain junk data, and prevent any undefined behaviour >>>> >>>> Addresses-Coverity-ID: 1544428 ("Uninitialized scalar variable") >>>> Fixes: dede1fea4460 ("drm/amd/display: Add Freesync Panel DM code") >>>> Signed-off-by: Yuran Pereira >>>> --- >>>>    drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c | 3 +++ >>>>    1 file changed, 3 insertions(+) >>>> >>>> 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 >>>> index 32d3086c4cb7..40526507f50b 100644 >>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c >>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_replay.c >>>> @@ -23,6 +23,7 @@ >>>>     * >>>>     */ >>>> +#include >>>>    #include "amdgpu_dm_replay.h" >>>>    #include "dc.h" >>>>    #include "dm_helpers.h" >>>> @@ -74,6 +75,8 @@ bool amdgpu_dm_setup_replay(struct dc_link *link, struct amdgpu_dm_connector *ac >>>>         struct replay_config pr_config; >>> I would prefer setting pr_config = {0}; >>> >>>>         union replay_debug_flags *debug_flags = NULL; >>>> +     memset(&pr_config, 0, sizeof(pr_config)); >>>> + >>>>         // For eDP, if Replay is supported, return true to skip checks >>>>         if (link->replay_settings.config.replay_supported) >>>>                 return true; >>> -- >>> Hamza >>> >> -- >> Hamza >>