Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934957AbdCWPEc (ORCPT ); Thu, 23 Mar 2017 11:04:32 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1072 Lines: 32 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 --- 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; -- 2.9.0