Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp753968pxb; Thu, 25 Feb 2021 14:23:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxtYva3jm1G9kl7sugYDtAEoYjuISDTXknOiV2hBnAHXtKSuNc4FmjCSLCGbZV22Uf6WEX X-Received: by 2002:a17:906:2bd6:: with SMTP id n22mr4957310ejg.91.1614291828914; Thu, 25 Feb 2021 14:23:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614291828; cv=none; d=google.com; s=arc-20160816; b=cVcegZvWNRZtTyUq1AbSxWThddKMFu3vwkxFew46xRPxeDWIyT38voTUTXYy0nRNUi QYFqu1Zt5fTgrSZd3iTqRtOEN7EJyxRX3evB5b32myYx14WMadPKdGHrz0VDiah72+ar AQOnqEEOSvgpntk5BCHzqic/s48AQqHdm2USpqVaf4S6gm6ivlq2ATV/t+aNtNim72hd w+UpVvowjENaMDe+Z9MVYkopbZgnbwQnQT/cPdQEM3crMMRWAjVAMObpIxLy9Eh6GgCt jNO9unaQGbytm97/rWg+w8eTL7RTLQEFVg7FCvI/JxMrqLKy0VVL5Jki4sOkby1GykrJ 9ctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=r4a3+s4Cr4ghjIOXuD7YCu2wxYZMNr5Kr9H6awJOdGA=; b=vu4rZ+JeBWjDotxD1d8fKBXTzzHC69Xw2K0CupojTUD4UE+1r/sgSNXrzvkmAUPG4q j60sVxsfO8L90KO7UUs+fjYkFses68EwFwl/vk77T/iUg/t0tJotmYL885eZ5v0ZHgcL DCK3jbu+7oILrxS1JnjxxJXZ9e9pxqBGaejzNU9KOCmq5vhrQ2VRsW1ErEeaM5YYBIQX shur3a9aTo6lhDpWCS1sVjkj4bEfGGcGsf+CyRSajoJBTkcbg79a64kKnObAnuQycWdm Zf/xVPtWRIXgTpq8D7/zmrpVywmpCth3SC2Ii1b8jLuaTIKGpz4IMkiL8bCDA8FX/YvO B/9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="p/ihU0Ur"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si4926515ejs.186.2021.02.25.14.23.26; Thu, 25 Feb 2021 14:23:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="p/ihU0Ur"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231822AbhBYWVv (ORCPT + 99 others); Thu, 25 Feb 2021 17:21:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234405AbhBYWRH (ORCPT ); Thu, 25 Feb 2021 17:17:07 -0500 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25776C061223 for ; Thu, 25 Feb 2021 14:15:44 -0800 (PST) Received: by mail-oo1-xc2f.google.com with SMTP id i11so251096ood.6 for ; Thu, 25 Feb 2021 14:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r4a3+s4Cr4ghjIOXuD7YCu2wxYZMNr5Kr9H6awJOdGA=; b=p/ihU0UriJ1G+zaM2B8ZoG3pX47dwZu2qqJmjam5qlENpz8t4tn+kOPb2ztOMxGlhU NIKkrZih48NbkY+/2gdH2JoGfg0UAogzCR5ubsjG8ddeeWTXkuVmlbAPQsPr7eqklEcI sPK6/rRKng0/m6CGl5gP1TwdOSn5efSbLP4St24DY4W2vDzdto7+lhgjfSvRKo+iNAb/ F9ghxM0aVSYoaXHRcWPN1z0cmnL0SlVVwwYt2FQ6MHc4HeYuzt/3kCHwWRlByHVxcxyS /I3Bu32j6luppCfxuwykzx8MTTG5ionbfKNK9NQ3+W9UTbT2W4xHFiuj1mKlN2p+PVf7 43Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r4a3+s4Cr4ghjIOXuD7YCu2wxYZMNr5Kr9H6awJOdGA=; b=g8t/ozXCk9k7i1fr7BAR43HBk+9QMgFLmRVSx9h56Mxz+V96NU/ITsrqUKvVDKD5pQ wa5LFUg4dgtCSO2015T6u17n+vEtvtTHnMEv7rFNYALPbqd9KKb63qzt+sxA5FJE7b2o ELn/e7cG/LS9ItpUOrpb7VHk/arFNVUFYSIrLqMIZH3rq/0TP0N0EzkuY0q9DNdEmKbQ 3Nmf7DG1KiVNmHfzVf5ijX70KplVzspJ4tXXSkaZ/uAAmultwkl2L0itC2EKFNLidt2U YV4jUblZIKszaKIv8zgfUwHozTPwgvHzh0Eka96RXFnLyCSFVMxyZ3G2NeZL8zHojXgR eimw== X-Gm-Message-State: AOAM530e78mxjPwy9hGI4JpZCGkRdAVAY69BWLlulBya5objLt+17UGv wPU9IptWbb72647cACcGfyKYzCme5/asvPMk55A= X-Received: by 2002:a4a:9801:: with SMTP id y1mr79967ooi.90.1614291343519; Thu, 25 Feb 2021 14:15:43 -0800 (PST) MIME-Version: 1.0 References: <20210225150119.405469-1-arnd@kernel.org> In-Reply-To: <20210225150119.405469-1-arnd@kernel.org> From: Alex Deucher Date: Thu, 25 Feb 2021 17:15:32 -0500 Message-ID: Subject: Re: [PATCH] drm/amd/display: Fix an uninitialized index variable To: Arnd Bergmann Cc: Harry Wentland , Leo Li , Alex Deucher , =?UTF-8?Q?Christian_K=C3=B6nig?= , Stylon Wang , Eryk Brol , Arnd Bergmann , David Airlie , Rodrigo Siqueira , Qingqing Zhuo , Nick Desaulniers , LKML , amd-gfx list , Nathan Chancellor , clang-built-linux , Aurabindo Pillai , Maling list - DRI developers , Bhawanpreet Lakha , Nicholas Kazlauskas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 10:01 AM Arnd Bergmann wrote: > > 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 This looks correct to me. Stylon can you verify? Thanks, Alex > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > 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; > > -- > 2.29.2 > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel