Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1759115ybi; Wed, 3 Jul 2019 22:55:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+eMXhQ75XV7aNsWa4EVcBWW+DLv7PG3AABeKfkWuE88K1UE+2EZApbQ534oI7Qmj/R8yW X-Received: by 2002:a65:6454:: with SMTP id s20mr39925565pgv.15.1562219716577; Wed, 03 Jul 2019 22:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562219716; cv=none; d=google.com; s=arc-20160816; b=Jjgjyr3JBdBED7s43vUUQz0y5JSE+0P1MEpYU/ukm09R0VE7F/Ub/bX558j2u3b6st Q85CsDO1mW0SofZQZSHkcAe9m6jTXnTvMx5Brk0820ROWgKBd6MYPmimGAdcBho/rg26 GVwPmh1FG45s6fDKkfIwBqFWgwP99ccbB4JIXxlDYk4AZHYparl5z0TvY+1uQqS05oSw TlvsM/PBkikT67kaKCCtlBVls7WKfrsMx4ZVd28LQARyUOkrIwAlS5oKKHjxDn7u50xG A1dfyGdK1/Rm3n9g+Yn6lpEFj+KjeV8UqtQEycwJocRvDPQER0eoa+6w+NG13YVN8gpa lOXw== 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=zFilk8inpqvXAk/7VOioDwq9okahAA+X1lVqweKxXoM=; b=s+SNmjxcjdviONMe//JL9ptDOp+uznacfwxB77ky2cP0eIlmUs0fB+yezm7Rg77c03 /KYGv4epmU1H4IUTRN/dPrSB3KI03OPyroRyPk4CsOSMxzxJr2rJw0goES580+f/rXQW xCsFnnpc7IglTMYp/QIwWzQwqlL+b5MJc9uCAw61tgBPcSUdQWLGpPO6ubp4AUkk8qOW +0V8R63e4bKk9T/t9zzHvZuuwjmEA41uwKtA5Ku3rsrjM6Btpg5H/HMwlwTJpOm2RRTc OapzgaPfIEg8oYYYIFidwv8R7HW/eZBhkJOkgdmJbda6fpvGvu+H8gJQ1JU+2r3i7ZlY Mu8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vCN1JcMz; 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 d6si4193285pgv.132.2019.07.03.22.55.01; Wed, 03 Jul 2019 22:55:16 -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=vCN1JcMz; 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 S1727365AbfGDFxC (ORCPT + 99 others); Thu, 4 Jul 2019 01:53:02 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:38372 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727389AbfGDFxB (ORCPT ); Thu, 4 Jul 2019 01:53:01 -0400 Received: by mail-ed1-f67.google.com with SMTP id r12so4240539edo.5 for ; Wed, 03 Jul 2019 22:52:59 -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=zFilk8inpqvXAk/7VOioDwq9okahAA+X1lVqweKxXoM=; b=vCN1JcMzPAY7/Tw39bVm1VyNdiPyea2R/hAHBGg6shiqhSTCl0vi3Fl/k0P9ZPWtcD fN844ICxUa05ilb7O1NX/2dcpDqQL/jQ0gQfQllMkkIfELHz0yoH7vMgqdu5Wku6NOqC jf0Aa0bV61JmAVZywNGeLDvFspJm3OCxmk4cU+Cvv5Wx5H8F0nMiEWqrN3eRTdPaA+gT Pf1ZLivIL5jjW+ZwA0LAjBQW6Ck4+zb7miSThxstmVBFe3dDr6kNEoN6LAsmF7OTbEll 79ujDc0k9FWhs9XDHg6DgYsXkvTrF49NWoNduURhAkLkzNhyFtLfpU0QTbrqWMuOLcxC OjtQ== 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=zFilk8inpqvXAk/7VOioDwq9okahAA+X1lVqweKxXoM=; b=NixpfT6TCslryuCJdiTNX2giHYX2MmZS54jVBMPsWJMPQzLawKjhErqvhytnfuq45t 5icb1DtBpF9tPVEWH6jvYj0yGSoKcEAKAzRHFdv7Flg1Zo0hOkWoMKTeLNlHzlwLfTXj qS4AnU2vsKfXm5qJ3XBwFtWtXXUfiNpdTr6htXyk4wm8AZY2EGDVtlHXj4PQ/dgqGyFp 4Btb4lf/QSCaUzDlGo5FFNg1s4hOftJEK9CfMuTIZ7Y3S/AxwQyPQAcfPTmBse5y0Xly gd4gHmUaIWP2peuPzF2oKuGYx8YH2Jm5Dg/JwMvDYaajvP/xe1Ks6YseICWtCVkNhUuv BleQ== X-Gm-Message-State: APjAAAUujn5TXGYBKxUcnE38zULuptZ3OFfO/+u4Mr/vMlGJEQTkYKgk Tj3IwcmcD9ekBVMhvglfep8= X-Received: by 2002:a17:906:7c8d:: with SMTP id w13mr37316234ejo.264.1562219578844; Wed, 03 Jul 2019 22:52:58 -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.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 22:52:58 -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 7/7] drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent Date: Wed, 3 Jul 2019 22:52:18 -0700 Message-Id: <20190704055217.45860-8-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/vega20_ppt.c:3023:8: warning: variable 'current_rpm' is used uninitialized whenever '?:' condition is false [-Wsometimes-uninitialized] ret = smu_get_current_rpm(smu, ¤t_rpm); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ smu_get_current_rpm expands to a ternary operator conditional on smu->funcs->get_current_rpm being not NULL. When this is false, current_rpm will be uninitialized. Zero initialize current_rpm to avoid using random stack values if that ever happens. Fixes: ee0db82027ee ("drm/amd/powerplay: move PPTable_t uses into asic level") Link: https://github.com/ClangBuiltLinux/linux/issues/588 Signed-off-by: Nathan Chancellor --- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index e62dd6919b24..e37b39987587 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -3016,8 +3016,7 @@ static int vega20_get_fan_speed_percent(struct smu_context *smu, uint32_t *speed) { int ret = 0; - uint32_t percent = 0; - uint32_t current_rpm; + uint32_t current_rpm = 0, percent = 0; PPTable_t *pptable = smu->smu_table.driver_pptable; ret = smu_get_current_rpm(smu, ¤t_rpm); -- 2.22.0