From patchwork Mon Oct 24 15:52:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101617 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp2651178qge; Mon, 24 Oct 2016 08:53:16 -0700 (PDT) X-Received: by 10.98.76.7 with SMTP id z7mr29812838pfa.143.1477324396516; Mon, 24 Oct 2016 08:53:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j127si16017611pgc.163.2016.10.24.08.53.12; Mon, 24 Oct 2016 08:53:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941096AbcJXPxK (ORCPT + 14 others); Mon, 24 Oct 2016 11:53:10 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:60382 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933767AbcJXPxJ (ORCPT ); Mon, 24 Oct 2016 11:53:09 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue102) with ESMTPA (Nemesis) id 0LyDvp-1d23gm0e9d-015bti; Mon, 24 Oct 2016 17:53:01 +0200 From: Arnd Bergmann To: Andy Henroid Cc: Arnd Bergmann , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] intel_idle: avoid theoretical uninitialized data usage Date: Mon, 24 Oct 2016 17:52:37 +0200 Message-Id: <20161024155259.3041159-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:J1SwjQNUc+64BOrJ7TRZBK33mk6pZs37X4CM5o1RF6b+560O7Nl idRYQKcyjAKIN9mYgPEA1IAjOfev/CByJAnnqR5oKWAQtKImbkRz+pRsG9aotSAMwdNrXb7 ByVrEc3HaEeVWSu3lmYfE554VAUN4pQHoJ78OiFhPpAPY99fC8PH0JIQbo8QawXlrs0wepJ uD93cGjeUcjhW82cRUmZQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:S9rVtx5glRs=:xwkaJxvllN4NLVW8HNlltH uou/D7IN74rplrbfEKtJpjtOw3Mb7ycVaMxjTMLAMOQnZvQcyNElxdZwturX5FU4p/xeI4dJM g10dqcHcGZicu26Lwdjgoz8LgloPrsej8r9HQtJUJDNREQszurAT3BnHkPE8isANXPlHwzxzM QE8iw0dkBpjzwZP/KPlPKpo1G8GW42S1d3bTFFWu2ztGCeZvfmp36Y/CqClaJcenB3nTZHAkw YOOq/HBvfkUFsKET9Di+KuRYguPpY46NRj/OGa3uOh6H+gh71K7IR5/1W42Wp6AD2YoQ36WmS 8rZSW6kwONDoIq0hZQ3jHOr0RH6NVpy0xMBxzWqnR91vmgIhOBpKtI57M65HFFtNinTyN3Fhf BX4M0LS1b44Rlv3fhxk1m/bg6RqNLkPk8iukaYlhyY4qQdu/tObnJfKbc2oOoA48768zjWc4T HOdWgXTgVKmVmC4cvJXZMMK6pJlUqFA+RA1bPaxA4FibBpTTUR8ZZjO1/jnNVVH4PoSegzxBm jR7U7zZL/7Qc76qEhCao2qK/31grIWPJhfjAwA70+zTb9zttXn9jZowzRbXaRC47MEKVB36RC +loED9E7tf/VOGB5NP0OMZhbEt1X2gNjsQDJPvQ+sRQlFgayYxVbNwrvRoi6VnnlGz6X5FWsZ orW/oRDM11qHgjLy/p2bAp3t1zYS3QNKVv6V2Ozpohn10ENuU6mXqiYcJJg9RyGtxxwraKxU3 B8PYEKf1Up2Ghymi Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When CONFIG_PCI is disabled, pci_read_config_byte() may not update its result, as indicated by this warning: drivers/idle/i7300_idle.c: In function ‘i7300_idle_notifier’: drivers/idle/i7300_idle.c:423:141: warning: ‘got_ctl’ may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/idle/i7300_idle.c:415:5: note: ‘got_ctl’ was declared here We know the function is never called if CONFIG_PCI is not set, so this is harmless, but we can avoid the problem by checking the return value of the config space accessor before using the result. Signed-off-by: Arnd Bergmann --- drivers/idle/i7300_idle.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/idle/i7300_idle.c b/drivers/idle/i7300_idle.c index ffeebc7e9f1c..9a104e558c77 100644 --- a/drivers/idle/i7300_idle.c +++ b/drivers/idle/i7300_idle.c @@ -347,6 +347,7 @@ static int i7300_idle_thrt_save(void) { u32 new_mc_val; u8 gblactlm; + int ret; pci_read_config_byte(fbd_dev, DIMM_THRTCTL, &i7300_idle_thrtctl_saved); pci_read_config_byte(fbd_dev, DIMM_THRTLOW, &i7300_idle_thrtlow_saved); @@ -364,7 +365,9 @@ static int i7300_idle_thrt_save(void) * unlimited-activations while in open-loop throttling (i.e., when * Global Activation Throttle Limit is zero). */ - pci_read_config_byte(fbd_dev, DIMM_GBLACT, &gblactlm); + ret = pci_read_config_byte(fbd_dev, DIMM_GBLACT, &gblactlm); + if (ret) + return ret; dprintk("thrtctl_saved = 0x%02x, thrtlow_saved = 0x%02x\n", i7300_idle_thrtctl_saved, i7300_idle_thrtlow_saved); @@ -413,14 +416,16 @@ static void i7300_idle_stop(void) { u8 new_ctl; u8 got_ctl; + int ret; new_ctl = i7300_idle_thrtctl_saved & ~DIMM_THRTCTL_THRMHUNT; pci_write_config_byte(fbd_dev, DIMM_THRTCTL, new_ctl); pci_write_config_byte(fbd_dev, DIMM_THRTLOW, i7300_idle_thrtlow_saved); pci_write_config_byte(fbd_dev, DIMM_THRTCTL, i7300_idle_thrtctl_saved); - pci_read_config_byte(fbd_dev, DIMM_THRTCTL, &got_ctl); - WARN_ON_ONCE(got_ctl != i7300_idle_thrtctl_saved); + ret = pci_read_config_byte(fbd_dev, DIMM_THRTCTL, &got_ctl); + + WARN_ON_ONCE(ret || (got_ctl != i7300_idle_thrtctl_saved)); }