From patchwork Mon Jul 8 14:07:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168651 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7215983ilk; Mon, 8 Jul 2019 07:08:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS0nKPJlbr8o2SGIpuEfVnLEwY1fZF8eoZXz/PNiJXszNRNm4hA99I/3lyaJwp0PljJ+Aa X-Received: by 2002:a17:902:ab83:: with SMTP id f3mr25273070plr.122.1562594906559; Mon, 08 Jul 2019 07:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562594906; cv=none; d=google.com; s=arc-20160816; b=mxriU2j25J8fA5AXdRGxSfngFHtDpHaXP7k85/KeSkOAyX7s/xUM3yij2AjH/NSAuG kRPZ21+HQTNliNCC5qm0HUVAiisUi9HsDnmYKBNOC1LjWJ1Wyk+yltdHNqDc4wL/EedK w3PTWgVkkNcE6owdoDlacuQ6ZSjkzxSzKkrW2nSUs2BEH13ZOnIV/ZtRyUao4/fyqeBJ YgqTHeAzag7Mj6UUytBbRlr7cvCpz6MiPpEvNOve5Zu3KtdG7ISkvkyKPRBesuMzcdOp LV2Ta4qPxVbWrfkmgmVodVLdPi4hN/xSclZSsKmtVK+c1xKjF1CnII/RIAjqWFRKg74j NIdA== 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 :delivered-to; bh=FyrbQNzwp9MG7dv3DXlM+kfu0DgSUDtuPtDLTaStA74=; b=in4mrrO5qoKoKzkljjsd5LpU70i9jge1gAZOKMb6LXqREJgcICAA7WeUKqESGa5FXO 9tgHdR2X6KYAD5ckou7C5hbUu5J6W6dnv96lZgaaeGSZkrOhJDEFhIJXqWNmdBy8kLZB NwZuM2qCgS0VU594M+F1D5G3EncsKe+1/KD12xM6D+Tv0ubQsEOXXm1c3emG4IH/CBbU SE00VgavzmsioeXbbj3cg1Eq1OeiCX6yE4XdIEn4kLsqWhVP/lZLOaDPjuRDpeaBPgtG s2Wd2ryr9lWwHZukQ1F1It7rlM4S9e8Oy6/kBwktKWnI6LZma+Xc9WFIygSZJpRIZA9S U1bw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id x185si20721652pfx.243.2019.07.08.07.08.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 07:08:26 -0700 (PDT) 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; 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 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F3EC89D8E; Mon, 8 Jul 2019 14:08:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id A3A5689D8E for ; Mon, 8 Jul 2019 14:08:23 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MMoXC-1i375x3FCu-00Ik9A; Mon, 08 Jul 2019 16:08:17 +0200 From: Arnd Bergmann To: Rex Zhu , Evan Quan , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter Subject: [PATCH 1/2] drm/amd/powerplay: smu_v11_0: fix uninitialized variable use Date: Mon, 8 Jul 2019 16:07:58 +0200 Message-Id: <20190708140816.1334640-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:X3J4e80NQyAuaqivhrauUEXEWU7jDdUAqZMBR/kGPcQ7CYCTHSi CIzF/Hx8mmfKT7DQSNax0/KaUiiTQnuK2hIJxk0dtFaoEHsVLxWeR+yR3fnKIhqt3Dfg4iP PIwtg8WqdZuu0vvm6p03mU3SVAQ/SbVVPQmeuP08r/dD1WfosPTHh5iYGmMh5e0Nlbbcmuq /M8IBS2hCeB21b3CZkm/Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:14Ii1zw6QsU=:dUxvAlUg7CH/JD12q86ZkC NPa53AjNYyMTTFb6PHM3SufF/j4+MnmcH24nLk8u0Hgn3Zjyt5+jIgUAsdj/FId5IDMeL/Liv nFyB93a5FGykJUhWnsd4/N7+WiKiZeSeKFiN0Wkl7LFFMw8iFr3+IjVvXXAbkP91ATFF0Ky57 Sjv+FZ05WJjs5A2oHVCsGp27DI94HU4OVvvM06CjWz+uVWaEXCeM6EYs+NNqDfLi75VqEWFdc xJltWBfGrxJgLug9v+coRVT7Min4kP/f1NnvKAuT0TL84cK3VbOCK/N9rwlVCBkSmdQljhiNd nzzBabj5pKnYUSWSsjizgTnUGaI7k8AWxy4JePuE0YNpj0iuFkvGMX/A2alZ/pnDBa36RMNp6 KLTjObokalL6XkDdWgC3m1QyHYwwH/nJke3R/tdvxXI9MeyFxQDjo5Gn/JGtW1TD/3BGVd7Ii p+eI9SipxqKZeL8C23nGph/LlsHXy/jHq+HQ8dwOAwjeVJ3IiDQFvGnkib+FZPah4RGd4gHS6 KetPom7A/2J3Z5F5XDDGeijFvIAYkQYOIBe5/ccHW7XwjieBCWCn0gSq0v8NkVz428AYUCWOP f/IYNPZfMsGCYPZHXFMb2OK+ig0J9/NSkIpixzmkcQY/IB/hpqCDMb2NGE/bJGZyPsIzvHsq2 DwE37KZqnY9akc5gRm42udStAewy3dM3SVFb+Q6RYG6YeSCx/E/OylqA1frsCZe/E1QbFUXJE hMQvYzIH57lCSq586//fOLaruyhv252i6sZ/3g== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chengming Gui , Arnd Bergmann , Kevin Wang , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Huang Rui , dri-devel@lists.freedesktop.org, Likun Gao , Hawking Zhang Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A mistake in the error handling caused an uninitialized variable to be used: drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1102:10: error: variable 'freq' is used uninitialized whenever '?:' condition is false [-Werror,-Wsometimes-uninitialized] ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:880:3: note: expanded from macro 'smu_get_current_clk_freq_by_table' ((smu)->ppt_funcs->get_current_clk_freq_by_table ? (smu)->ppt_funcs->get_current_clk_freq_by_table((smu), (clk_type), (value)) : 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1114:2: note: uninitialized use occurs here freq *= 100; ^~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1102:10: note: remove the '?:' if its condition is always true ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); ^ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:880:3: note: expanded from macro 'smu_get_current_clk_freq_by_table' ((smu)->ppt_funcs->get_current_clk_freq_by_table ? (smu)->ppt_funcs->get_current_clk_freq_by_table((smu), (clk_type), (value)) : 0) ^ drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1095:15: note: initialize the variable 'freq' to silence this warning uint32_t freq; ^ = 0 Bail out of smu_v11_0_get_current_clk_freq() before we get there. Fixes: e36182490dec ("drm/amd/powerplay: fix dpm freq unit error (10KHz -> Mhz)") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c index c3f9714e9047..bd89a13b6679 100644 --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c @@ -1099,9 +1099,11 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, return -EINVAL; /* if don't has GetDpmClockFreq Message, try get current clock by SmuMetrics_t */ - if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) + if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) { ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); - else { + if (ret) + return ret; + } else { ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetDpmClockFreq, (smu_clk_get_index(smu, clk_id) << 16)); if (ret)