From patchwork Thu Mar 23 15:03:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9641413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 393CB601E9 for ; Thu, 23 Mar 2017 15:04:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AD8F2787C for ; Thu, 23 Mar 2017 15:04:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FA7328475; Thu, 23 Mar 2017 15:04:39 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C73252787C for ; Thu, 23 Mar 2017 15:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934933AbdCWPEb (ORCPT ); Thu, 23 Mar 2017 11:04:31 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:56807 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934737AbdCWPEa (ORCPT ); Thu, 23 Mar 2017 11:04:30 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0LsyLK-1cAUBN2T2A-012a6O; Thu, 23 Mar 2017 16:03:31 +0100 From: Arnd Bergmann To: Luca Tettamanti , Jean Delvare , Guenter Roeck Cc: Arnd Bergmann , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] hwmon: asus_atk0110.c fix uninitialized data access Date: Thu, 23 Mar 2017 16:03:11 +0100 Message-Id: <20170323150323.271584-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:x1Ghiy0Svs5uKmkHZkgslyA/0CoxzBNiVqi/AsvYzE3g/pwpBlX vSsqMDW7RsrLd1tCSPv/ABUF32cz9yLVWLJ+u11Ee0q4wtPQB0aQoLlR0M9WCuGEX8Ih5iD 4Yz85ql9v13JLOS/DOsHoMVfJLX0Le8+FxmORhhKsO9vOCs1IRquRKVoDwtTNPE9p78EeS5 FBera1ELojxdZXxtc/rEg== X-UI-Out-Filterresults: notjunk:1; V01:K0:RSm/gjeWvgU=:oJJ8xiwNKnTHa/A90orVak BkC6/4XU0C520WnHj5TlnogKjskVP1Ix2rXPDZVDEdZHBquKcQ4S56fcxz8gT8WiLZ5J3qxTH M0mLr6id9szn+vNjm64zC/63tsW2nPuPKWEsbVMi+yrRA/RzeDsrx8n/tnu/xv/X+8nvhqBS2 Ok+sriB8jWuSdQ42GvKt5liL6GJ7fo5lO9aWoIaO0ePZ96HhKwScEl5qGE2azDGqxP3QLq+Es 0AhYKfwWjsUuAfnRh5oCpJNe0DUrPDnSrY9sq6tKB0DCWgWileRXpzCAEiu5PIB3Uds8x7lVm sD7K9xCovQZD/LDbIBsCMGuxRPkS64iF8hYiepoHLy0XWYbxL3A8wRfJNLRx+W6na9fwWfA60 Ogk13BRBAcmfKHyLM4L1ij/xorLTzyhtD3Th4gtgowrU7fcUW3HIGJxToJJuJwiI2RyYAdVMz YPYsIpiuoH65Nq6B2Eck/f520WvZ593trmuMBCS1jaFA5AKEK1juHhh9dJ3n3VK0XRjsGqAP8 ODWkzv7T9+VnQRXFa5oaQrLg2cNfgQRXv1ushc59Iw5hXm878VtmnjkcgKFsc/f2qosAw7gBb F/YmWcFrOJcTaYyNaCViKAvEIDginbeUiNd7eo5Jdac8Z/ObVhEifygN1CZqLcH/BEMWotxz6 O2FXc8xmaKLqY0oP0+X0Z99Pvsi1sxg3tFV344r/1UMOz8vVJuTdjd7F8qu9nBck3Lyc= Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The latest gcc-7 snapshot adds a warning to point out that when atk_read_value_old or atk_read_value_new fails, we copy uninitialized data into sensor->cached_value: drivers/hwmon/asus_atk0110.c: In function 'atk_input_show': drivers/hwmon/asus_atk0110.c:651:26: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized] Adding an error check avoids this. All versions of the driver are affected. Fixes: 2c03d07ad54d ("hwmon: Add Asus ATK0110 support") Signed-off-by: Arnd Bergmann Reviewed-by: Luca Tettamanti --- drivers/hwmon/asus_atk0110.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c index cccef87963e0..975c43d446f8 100644 --- a/drivers/hwmon/asus_atk0110.c +++ b/drivers/hwmon/asus_atk0110.c @@ -646,6 +646,9 @@ static int atk_read_value(struct atk_sensor_data *sensor, u64 *value) else err = atk_read_value_new(sensor, value); + if (err) + return err; + sensor->is_valid = true; sensor->last_updated = jiffies; sensor->cached_value = *value;