Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1757704ybi; Wed, 3 Jul 2019 22:53:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6MYIef3JiLRTj6gqkUKy7E3pNxbIRPqXhqOts7V0EBZ2L3i/8/kOp8T7bwyElHsMv89xt X-Received: by 2002:a63:e53:: with SMTP id 19mr41043542pgo.137.1562219621373; Wed, 03 Jul 2019 22:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562219621; cv=none; d=google.com; s=arc-20160816; b=x97hn7eeZMct8x6zsqj1IbsgPW70l4PMG8mFQU1AKcirpYcksAdxfMi5yAwgcEop8b QDhgMfAjbhE6Co7FCqtx+IMxhJxrrUaxiQh+MLEU+Ga1HcizHgMVT7DfNkxRu4E/5j6R EKU1yjHpL11ZUuCkcVdORVfrmrqRPeTH4sEUlgGgTfIE4GVbl9VsT4bBtlEZHYQQEraW IQe6/9Cp/ALTl3bZjCii9PPw8zhB8Re0rJ/e+fgJIuoeOjevY4j3ig1SkhWNY7/8LCF8 Zlo3zlGnt9TEONm6Ee6P306EQGhWXBy8uyMDo5ljxhhYWwSjKxV6izkdrrAFoD4LjLbc AOuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sk7x/uIvEdvnOhCPEBQK8xnGMTAhDlc8g18Tgsd50+s=; b=G+1U+xUcbKiGa1frx/z800FrOc70bByRgcANwFPF9xyZHcmUohj+TH1LSsGCTwCqu5 bE2ZCpd2vJVxykErrvNT/Kf0RvE2e7Uiy9OeF2BPmeCAmE7sfD27ornPy1URw4AmVZs7 kT9dMYtlA6fcJ2S9mRDgej4VRFFzdNGe8YxdkwTCYgd9uzlheDHBKl1m/4xN6q9GVedt VJ5VNWgn/bsYjeHqmdyGkoGgkOpsmFJaHUZY+OgPFSGF9LXGkC2G6tPuEzf2T1XviEuc OoRz6eHVk3ESGOdN6OLR9JALmBfBs6MRH7LU3NCL7pg8DkW3gxLLh7h7qqRWHCARFwfl H3fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X31O77dj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d30si4410201pla.419.2019.07.03.22.53.26; Wed, 03 Jul 2019 22:53:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X31O77dj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727375AbfGDFw4 (ORCPT + 99 others); Thu, 4 Jul 2019 01:52:56 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:38361 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbfGDFwy (ORCPT ); Thu, 4 Jul 2019 01:52:54 -0400 Received: by mail-ed1-f67.google.com with SMTP id r12so4240363edo.5 for ; Wed, 03 Jul 2019 22:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sk7x/uIvEdvnOhCPEBQK8xnGMTAhDlc8g18Tgsd50+s=; b=X31O77djkxsK14FGB/XNRtzgI/6Xi8+vcGgZzqR51BVRF9R51PjC4m7RTkRWKcpRVq oPNOSfHC1eU7T7y0WBDld+PMP6AJtu7YVdUufwqCvWNVJiQzSh82vqi8FwY6nr4ACp6i 0MBcMyaocwVoW5Hl2mINO8yaxMGY3K/+XDt7GyXma1BG7pLVDvHvAjQeSX3FvSXBIWVZ RQX28ykaX5qfvfFJTYtHXVUD5etlX5vXudvbKTqeIxYUhDpfHDsjUwuF6tzv4m2MQvvI RzNt6/5acyN/+BA+HP+S43FWgIJYFUGFJNZxkjfCcoWKbu+ID32EBPX6qhOQWudpIosv kzCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sk7x/uIvEdvnOhCPEBQK8xnGMTAhDlc8g18Tgsd50+s=; b=h0xiBBLAy4MmMvCWf4Lp+sBaAz3XQ+eeE7A/ztkyHiW/jGeZqYFMeVqT9kgefhA/cO tl6xMnMGVWZ5Dnn1yMaTFDX3UaaYB9iOkLex0qb/1jAcE8faVDX5kPoBGYIyi3veCsja DsdJCVM6sIzOAJE+I+oHPBM8nWw2lzPy6wxSFHnYN8qZctB1S1udCzWltkmObwKwqpLB epXPTTQe7BJC6mNxFx04s++3LeCFfQFTASIOSClmr4U9jKCtEWtuWW/2/IjChdQHtCZn cipAX5aEv2ojcdPQqFMvVNQfwVJbbg4vxUAeOvNHtKL2oV/yJME/r8hucuKx5ZqjQCIn LnYg== X-Gm-Message-State: APjAAAUaooUXGr0gY9QYmcAOSrTM8tdxwHvC0RRr3VN5Z2vd3Cz5zpqt YuAdONaI74AyXdCMFqP7TPY= X-Received: by 2002:a17:906:edd7:: with SMTP id sb23mr28250772ejb.309.1562219572730; Wed, 03 Jul 2019 22:52:52 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id j30sm1343532edb.8.2019.07.03.22.52.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 22:52:52 -0700 (PDT) From: Nathan Chancellor To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , Harry Wentland , Leo Li , Rex Zhu , Evan Quan Cc: David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH 4/7] drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq Date: Wed, 3 Jul 2019 22:52:15 -0700 Message-Id: <20190704055217.45860-5-natechancellor@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190704055217.45860-1-natechancellor@gmail.com> References: <20190704055217.45860-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clang warns (trimmed for brevity): drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1098:10: warning: variable 'freq' is used uninitialized whenever '?:' condition is false [-Wsometimes-uninitialized] ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If get_current_clk_freq_by_table is ever NULL, freq will fail to be properly initialized. Zero initialize it to avoid using uninitialized stack values. smu_get_current_clk_freq_by_table expands to a ternary operator conditional on smu->funcs->get_current_clk_freq_by_table being not NULL. When this is false, freq will be uninitialized. Zero initialize freq to avoid using random stack values if that ever happens. Fixes: e36182490dec ("drm/amd/powerplay: fix dpm freq unit error (10KHz -> Mhz)") Link: https://github.com/ClangBuiltLinux/linux/issues/585 Signed-off-by: Nathan Chancellor --- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c index 632a20587c8b..a6f8cd6df7f1 100644 --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c @@ -1088,7 +1088,7 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, uint32_t *value) { int ret = 0; - uint32_t freq; + uint32_t freq = 0; if (clk_id >= SMU_CLK_COUNT || !value) return -EINVAL; -- 2.22.0