Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2718896imj; Mon, 11 Feb 2019 07:27:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IbGm3ly6WdpZ6Kw71jISeX/fa10cgSu8L4UDcEHsfKkskK58Dw5AsX5RADvPXXTxwEjFADu X-Received: by 2002:a65:488a:: with SMTP id n10mr24530679pgs.261.1549898875124; Mon, 11 Feb 2019 07:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549898875; cv=none; d=google.com; s=arc-20160816; b=VTsBzjR7xkaj1Mg6d8StrP4jNt9xQ7PJS124ulWFF7rwH8TD9c3sswyZLnfm5fEb48 PoOO0EQKwHU6ViJg5aunYxx+Te4JxDaBN69mSlXBJRTMzDrK3Kv8Uvy9jIdsrSpB4sR1 L+QSSfV39WZXT8lRNE0SmKuYlZrp01mmvbZO+SIjqO/b0hkbdTQqwYRPCFMCUA6S7Rep F1TXtE2PMqMl45353mPdCGrNGAe/VXUbN24ivLO8xIPcCjk7OxBeMUSKavqDG5/N0pJC rizgRJu3By+9qvmWRdUN7PY43RAgDHkRSrsbp+75KY8EIp99yA8XuW+KNbYIhhhSoqvO LUWg== 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=KwgFLrO2shmhbS2bCwFpN+1GuEQujK/ph/kkXjxsuxM=; b=ciDBBedkH50o2PRHJcMWPprpkC8ZT6Kv/V+a26Za9Vwl3toGx9b4rostt7ti+52SRg HEUpwa4hu0ETkPmgLFiGKBuvw8QlmLUP/7W4oCnebpmuZT4qMK11nuu1tGWHJxz1Zu9N JD3HnKOvqKNrj2yYhuE/YHB6XSSNgPztsoh40h2gUCIGUqUH/NUUClYUjqCnYla82Sqg Ut1ERBAw7ewTptn5tXOb7D9rqhqg4w8iCCzrkuIdX14f8u70MJNBQu2qMG8HwZgQbKWF wNIuD8H+h9iWztuMF+l+y7xexxW8b8B4oVJij9+LsraeVyHnZZpzKXC32jz1Mvj27e5i mJFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gxRN6jEo; 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 e4si12108272plk.300.2019.02.11.07.27.38; Mon, 11 Feb 2019 07:27:55 -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=gxRN6jEo; 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 S2390055AbfBKPAl (ORCPT + 99 others); Mon, 11 Feb 2019 10:00:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:48648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389294AbfBKPAk (ORCPT ); Mon, 11 Feb 2019 10:00:40 -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 8347921773; Mon, 11 Feb 2019 15:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897240; bh=nAuDK9DMkQ6pxZ50aCqI2Fk+cJz2dWXu0RVQXE4s05A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gxRN6jEoljaki1dic092/wg6SFIHcWb8G448m/0agCvqalfW0dMJdc711uInK9TG6 VqN69n1k/IuegcN8rUbf6d10Xrffw64yXb7k3gslwDcD3zVs4+ciYn434+PPqmgm7Z FOYNHxt9cHWn81pl0HhKXsst4yekayEhcoYztF1w= 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 136/205] hwmon: (lm80) fix a missing check of the status of SMBus read Date: Mon, 11 Feb 2019 15:18:54 +0100 Message-Id: <20190211141837.287206956@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 c9c63915519b1def7043b184680f33c24cd49d7b ] If lm80_read_value() fails, it returns a negative number instead of the correct read data. Therefore, we should avoid using the data if it fails. The fix checks if lm80_read_value() fails, and if so, returns with the error number. Signed-off-by: Kangjie Lu [groeck: One variable for return values is enough] Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/lm80.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 08e3945a6fbf..04f9df0d2341 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -360,9 +360,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, struct i2c_client *client = data->client; unsigned long min, val; u8 reg; - int err = kstrtoul(buf, 10, &val); - if (err < 0) - return err; + int rv; + + rv = kstrtoul(buf, 10, &val); + if (rv < 0) + return rv; /* Save fan_min */ mutex_lock(&data->update_lock); @@ -390,8 +392,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, return -EINVAL; } - reg = (lm80_read_value(client, LM80_REG_FANDIV) & - ~(3 << (2 * (nr + 1)))) | (data->fan_div[nr] << (2 * (nr + 1))); + rv = lm80_read_value(client, LM80_REG_FANDIV); + if (rv < 0) + return rv; + reg = (rv & ~(3 << (2 * (nr + 1)))) + | (data->fan_div[nr] << (2 * (nr + 1))); lm80_write_value(client, LM80_REG_FANDIV, reg); /* Restore fan_min */ -- 2.19.1