Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2686296imj; Mon, 11 Feb 2019 07:02:15 -0800 (PST) X-Google-Smtp-Source: AHgI3IYuN4HiI66OUYnXTfb27dcGxJCY/jvD+PQFICGszNf1oo/s4hJBoGYzYvVOwmPl02n3QtIm X-Received: by 2002:a63:2312:: with SMTP id j18mr14948862pgj.344.1549897334978; Mon, 11 Feb 2019 07:02:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897334; cv=none; d=google.com; s=arc-20160816; b=RIY2NSq9ou4RZzn6tz0Ucb4KWhR4oV2aVZDkYnQxvAg9GXc470i0xsJA7onz9Ogchn P0Lx7tSs0Oot8B/FC5i/exv5QJfnib5gwyZ/dNXVd7vt1ff4SVAmaqIfl6j1Jp6bcb9D z5QAde20GN9wCxJOid2IV3YCooMb35QfJtmiXzoeUAjI9bVMFqdm+zLfquEgTGx8r8mJ 2DHJaLcSDp4ug3AFaewjoAsc82FculGCgk2Fhxt/H4vGRfd/2VjT9F7xinSys8jlhIYH /5zFudyUi9BY/a4Wn82hxtRyyInyx9L9qYQkE63kcmiPvOyWgMKRCIfI4wMf1NZvNVeJ kYPQ== 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=kOcWjWPGFee63bdIFRF6OItr80bwzMe/0r6ku5plwTM=; b=ioEo3lznioC+4Owm8/YtlO33su0mJXcaoBmkbf5HtAkEXnsmwx6xJe0ROb+QEOWg+p Vpxn/eiNZMxfXI07CHv6UkDmws+rXIUDIFjyAMjTndgff5Il2+YXMZ0q51H8720I007A flOhvC4XmHodrkiGG4ZJ9lZhbagD/iSyGe/bgAwMd0QnorQyyxGI156h+e7BRXCOfu53 IuY2qJ87G6nhsO58J602l+QJow6qvRPy9ut7AQA4CyYH13q7GNC/sIX83WjWP2Id4fGZ x4xotG1zBdRWmbCjb1aaHK8iumv+PDNQ1pe7QWoHFuEUglL2+c0MCqCow+qHrc8slZrr XI4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2IDEq9C+; 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 p80si10114793pfi.124.2019.02.11.07.01.52; Mon, 11 Feb 2019 07:02:14 -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=2IDEq9C+; 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 S2390073AbfBKPAs (ORCPT + 99 others); Mon, 11 Feb 2019 10:00:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:48694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390060AbfBKPAn (ORCPT ); Mon, 11 Feb 2019 10:00:43 -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 29B12206BA; Mon, 11 Feb 2019 15:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897242; bh=aCJfhwHXmx/qLPNtEBO5lh3oM/AafAbznhfC82lpq4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2IDEq9C+3czZRAFVH6lYw8j2hjaS1FENaOOs3fnifHi1BDGoYTID7agE5swFt1eah JehUFn7v5A5BAaw7Jnd46FMzlXTtmNHYEFxaTY7DcGUo6IuTCS/f80YrMPrU35oL3W D1qDkzJbzsCI37iEkz+x1JxJNPo70XZ6YIm2uUGY= 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.14 137/205] hwmon: (lm80) fix a missing check of bus read in lm80 probe Date: Mon, 11 Feb 2019 15:18:55 +0100 Message-Id: <20190211141837.344278836@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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