Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2752813imj; Mon, 11 Feb 2019 07:59:36 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia0k2+Fzw+zhcAVY5TuRC6cacdmJmlLkpp13gI1x/U9VWTChk6MLTg5E9KcEk+KDeKjgwcS X-Received: by 2002:a17:902:42e4:: with SMTP id h91mr38559356pld.18.1549900776147; Mon, 11 Feb 2019 07:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549900776; cv=none; d=google.com; s=arc-20160816; b=W9HCoqFlATDUL3J7n9DKruDHR2au/Tj/0pRniRKsYb6xEOXov08gtlAWzKuRTQNGR4 2uBR4odszlJNlVWtZMsyIWuS6UVsFJyjnPlJzCwT01zWp7HWpdWeMBqEKmEAqTNBBgIU sNgPUG9XksJqsK+UUTTmzYhC3MtUKm6mYo1Qd+X90LgRjqTwa806oi8XaRg+9bwVPhbn +v1ZRJghNHSTM7UpkBztgQNFvjsXbIJoaoJh9xVEMapo1DcvNeseSMtSM60jIy3/Fcaw nwZ9gMzDR65C205wfwSUOswR4MErSGGKsZpdtxdjQWSk4NxugkGoI5eajoS2bTLKhXns 2QVQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=53ERfHIJAxIXa4OMsQ78AL54XG7v0x+DxPa+0zjmlOQ=; b=WguP4VUAJm2tml1R41iHa4uQcfiOBF/Dj4T0zZlLrOIXHm7fdfCwEVXlihslDgHC0G dNx7Cu90lPIL9n0BVOr0j20UPtHo1KjqcB0QhKy7MlyR4yHwhhLyHxH29sTonFug36SH d56JWzjGsE2H2t8UB+hXUmls5SgdQZVsCsxSRr0NygHGnZICJilIthFk4Oyqyg5QJeTK 8eMLXdH4mzHUxAw+ElDpFJvPS3DfHo6AvfY7nvVs7Zpd+YNfPylNgaDV3sK+W2HLIx// Jm09XiPXyR1CbPKD9tlS9uHKKK6HKuwGI2kvG+wZ67AK3TtciBbeM8B3ItKFzpSsabBv n+Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o9yB72ev; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si10257432plo.319.2019.02.11.07.59.19; Mon, 11 Feb 2019 07:59:36 -0800 (PST) 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=@kernel.org header.s=default header.b=o9yB72ev; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730569AbfBKOdB (ORCPT + 99 others); Mon, 11 Feb 2019 09:33:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:40566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730552AbfBKOc6 (ORCPT ); Mon, 11 Feb 2019 09:32:58 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F080820675; Mon, 11 Feb 2019 14:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895577; bh=KZt+uJOdGtv9LZw9v9/botkkhNIrXxcqavLa38Cwh44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o9yB72ev8zxPTWo7iO6JPOFNc+0ABtC2yqh2im0NMoPFyUUT8X2UaFy5N5mE+i6K2 RgqAUfjGWcYDUvPIhMh5qJ+/Fn8utepCjwKkGAQsSYBMlSNhUWW/PmD3JWzMYuPa3D sOvc+kZ0Z9tpAaEMAFc9Q/H6l1mfP1awzCVc/UWU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Guenter Roeck , Sasha Levin Subject: [PATCH 4.20 252/352] hwmon: (lm80) fix a missing check of bus read in lm80 probe Date: Mon, 11 Feb 2019 15:17:59 +0100 Message-Id: <20190211141903.127252087@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 9aa3aa15f4c2f74f47afd6c5db4b420fadf3f315 ] In lm80_probe(), if lm80_read_value() fails, it returns a negative error number which is stored to data->fan[f_min] and will be further used. We should avoid using the data if the read fails. The fix checks if lm80_read_value() fails, and if so, returns with the error number. Signed-off-by: Kangjie Lu Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/lm80.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 04f9df0d2341..0e30fa00204c 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -628,6 +628,7 @@ static int lm80_probe(struct i2c_client *client, struct device *dev = &client->dev; struct device *hwmon_dev; struct lm80_data *data; + int rv; data = devm_kzalloc(dev, sizeof(struct lm80_data), GFP_KERNEL); if (!data) @@ -640,8 +641,14 @@ static int lm80_probe(struct i2c_client *client, lm80_init_client(client); /* A few vars need to be filled upon startup */ - data->fan[f_min][0] = lm80_read_value(client, LM80_REG_FAN_MIN(1)); - data->fan[f_min][1] = lm80_read_value(client, LM80_REG_FAN_MIN(2)); + rv = lm80_read_value(client, LM80_REG_FAN_MIN(1)); + if (rv < 0) + return rv; + data->fan[f_min][0] = rv; + rv = lm80_read_value(client, LM80_REG_FAN_MIN(2)); + if (rv < 0) + return rv; + data->fan[f_min][1] = rv; hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, data, lm80_groups); -- 2.19.1