From patchwork Thu Jul 4 05:52:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11031083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5D6414DB for ; Thu, 4 Jul 2019 07:25:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A21CE287B4 for ; Thu, 4 Jul 2019 07:25:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95F982892A; Thu, 4 Jul 2019 07:25:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 504DD287B4 for ; Thu, 4 Jul 2019 07:25:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C97876E27C; Thu, 4 Jul 2019 07:25:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 42EE36E261; Thu, 4 Jul 2019 05:53:00 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id w20so4252599edd.2; Wed, 03 Jul 2019 22:53:00 -0700 (PDT) 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=XFzbOrZklKngTdhpWmOGekiyy/dcnmRfJkIZfZNYh8/ZTrJzVz/v905ANzFgqxKeKY 2bgWkFQN2PiAMlX0cIVzIy7IothpJIMag2mjB6/868OU+3dGTBQt3nlljbt7jrq5/Dy2 bKEYkNavCckY5TnDcCA+PY5xaKsgQl9acHUpXwVe+kIzX4iousgq4rJsBHhQUbVcJdpR nUvrNy6FJSzRb0I2DRlPLHvWt7He8pTgCK3SSXNZO2Cuj9gng+0kybczX4ZdDYl2tS99 0buNkqZ8hV+qytexhEhVAaP+opne+Qlrld92uGl3hUMDMnaLD53ss+Qwh7aQtSVXJ3jX GREQ== X-Gm-Message-State: APjAAAXZCHDRqY9U5AOtSW9uDJYajBQFc7aBg431j+eOqvtmKMEsVoSl 9TlL7gLzZ4VyLC95OwwJDqI= X-Google-Smtp-Source: APXvYqxrxXJqrMJF2LmfwiNUZ/GEweI6LA1cX8k67/CpoxPX7tAyR0f2GpL/tEM3wB3rH5vK7MV5Yw== 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_K=C3=B6nig?= , "David (ChunMing) Zhou" , Harry Wentland , Leo Li , Rex Zhu , Evan Quan 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 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-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-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: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, clang-built-linux@googlegroups.com, amd-gfx@lists.freedesktop.org, Nathan Chancellor Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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);