From patchwork Thu Feb 25 15:01:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 387223 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp380325jap; Thu, 25 Feb 2021 07:01:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3cELITJbGAz3DnoEtlXg6zz06epdEL2XX/bsTVMqFXF3GA6viilO/Ip/EBuN2JrEN7/Wb X-Received: by 2002:a17:90a:1b27:: with SMTP id q36mr3639245pjq.133.1614265291298; Thu, 25 Feb 2021 07:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614265291; cv=none; d=google.com; s=arc-20160816; b=eJgJnkLaZdlI0g432oa57y6gbcfdgylzJqEwU05XVUKDse17V55FlHc7JnQDSH1HKJ wkPp9yFOb14zyvTrBGTJcoLjvcH4aCGxQ93/gvJvYybDI6N/tA5e6A5iOnLjqdt1P3Te Vs07wkfviGIOYLMdwX2y0kgVkbfnn2KnjOLhhL177mtkvQIipqkFnA61ToVDsxu9Yy40 vzVTwoy/u9L+9+eSqlQTInaDvBt1EVUgptuVFFh2+a9apw0VmrCwEbcrCe2SHNBriW8e wa5FWWN36pY71c6j4K33DvOa60+vpcYGRl1v+/yTk/UsYYJ0KvZle5i9W48o2VN3/Mum jK9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=TSscybrlgk1yptYY8Zx6sRemxz4Qt2YptclFKkMlyDo=; b=NZA/EOtXDOU95xUTjSyXTFaKS+wKD/jwgqsATCxC4lJIMrj5r0U6gmL6scP7faLomx krQS1/soC6J1XVvsKZIlvx59LXkb6mVo8FEsojDD3XclSvFmxbPS5Yh8wU0cYHvOY/Bu xM+RC0TpMDtKWzzyMw15Jcj2fLU0g4vA4iLkEZuICEWSPf+muH4SUDTSLC0r0msY3LIk 8kY1N5WYRMzRhIHgy0o6YV7SOIK71djGuKKwjoVU2xRtiy40muthKhvV8Y39lU7SAwl3 8z7a960nXL4CwM8C4ASAPzfPgTo1QgkAI9R1H0zygpCtqPwcIZuN//U4/tSIMfiKJet2 MiKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=jYFhNaZb; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id y15si5455095pgq.55.2021.02.25.07.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 07:01:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=jYFhNaZb; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A4506E1BA; Thu, 25 Feb 2021 15:01:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id A55736E1BA; Thu, 25 Feb 2021 15:01:28 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id DB3B764EC3; Thu, 25 Feb 2021 15:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614265288; bh=rTp6tlRl/+2dDCi+5gBT4LR+IqVuF5cDPLNiC8PJHgk=; h=From:To:Cc:Subject:Date:From; b=jYFhNaZbbSoTDYljzbyuXXwgaGElH7/NWFsFNQhQ0ZoAdxEgpmjKWwUUu1s2Fli55 9FL9kT4HbFgnoCICaopvKBMhYoCiXfOXBFuMEVE8k6Q84QY9hsCwa5yJHoyViq4v1X EX7tPknLeA2y0OW0L5A8mWn1P2bv6+vBhgqELGcPZG8j6su4kf+Kg+/L96oO+quyl6 71p38s+XZbNuKnAKIhqqAX3KgeM5DPUWGgkFGbfSeHNJLnPQuoalrJrn6A57tV3ngW iaX1C009z+deiIsRBEnQ0n2G5zZ2RRY5moTt6Lf/Fvl81G5WA1QbJOXFi9UVJXZlmp eWEboNG471QWQ== From: Arnd Bergmann To: Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6?= =?utf-8?q?nig?= Subject: [PATCH] drm/amd/display: Fix an uninitialized index variable Date: Thu, 25 Feb 2021 16:01:02 +0100 Message-Id: <20210225150119.405469-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stylon Wang , Eryk Brol , Arnd Bergmann , David Airlie , Rodrigo Siqueira , Qingqing Zhuo , Nick Desaulniers , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Nathan Chancellor , clang-built-linux@googlegroups.com, Aurabindo Pillai , dri-devel@lists.freedesktop.org, Bhawanpreet Lakha , Nicholas Kazlauskas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann clang points out that the new logic uses an always-uninitialized array index: drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9810:38: warning: variable 'i' is uninitialized when used here [-Wuninitialized] timing = &edid->detailed_timings[i]; ^ drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9720:7: note: initialize the variable 'i' to silence this warning My best guess is that the index should have been returned by the parse_hdmi_amd_vsdb() function that walks an array here, so do that. Fixes: f9b4f20c4777 ("drm/amd/display: Add Freesync HDMI support to DM") Signed-off-by: Arnd Bergmann --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel Reviewed-by: Nick Desaulniers diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index b19b93c74bae..667c0d52dbfa 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -9736,7 +9736,7 @@ static bool parse_edid_cea(struct amdgpu_dm_connector *aconnector, return false; } -static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, +static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info) { uint8_t *edid_ext = NULL; @@ -9746,7 +9746,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, /*----- drm_find_cea_extension() -----*/ /* No EDID or EDID extensions */ if (edid == NULL || edid->extensions == 0) - return false; + return -ENODEV; /* Find CEA extension */ for (i = 0; i < edid->extensions; i++) { @@ -9756,14 +9756,15 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector, } if (i == edid->extensions) - return false; + return -ENODEV; /*----- cea_db_offsets() -----*/ if (edid_ext[0] != CEA_EXT) - return false; + return -ENODEV; valid_vsdb_found = parse_edid_cea(aconnector, edid_ext, EDID_LENGTH, vsdb_info); - return valid_vsdb_found; + + return valid_vsdb_found ? i : -ENODEV; } void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, @@ -9781,7 +9782,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, struct amdgpu_device *adev = drm_to_adev(dev); bool freesync_capable = false; struct amdgpu_hdmi_vsdb_info vsdb_info = {0}; - bool hdmi_valid_vsdb_found = false; if (!connector->state) { DRM_ERROR("%s - Connector has no state", __func__); @@ -9857,8 +9857,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, } } } else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) { - hdmi_valid_vsdb_found = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info); - if (hdmi_valid_vsdb_found && vsdb_info.freesync_supported) { + i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info); + if (i >= 0 && vsdb_info.freesync_supported) { timing = &edid->detailed_timings[i]; data = &timing->data.other_data;