Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933824AbdCJJSQ (ORCPT ); Fri, 10 Mar 2017 04:18:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36954 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933188AbdCJJSN (ORCPT ); Fri, 10 Mar 2017 04:18:13 -0500 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Folz , Guenter Roeck Subject: [PATCH 4.9 032/153] hwmon: (it87) Ensure that pwm control cache is current before updating values Date: Fri, 10 Mar 2017 10:07:45 +0100 Message-Id: <20170310083949.062490648@linuxfoundation.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170310083947.108106897@linuxfoundation.org> References: <20170310083947.108106897@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1160 Lines: 39 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck commit 82dbe987b70042b340f851bdc969a971081e5f02 upstream. If sensor attributes were never read, the pwm control data has not been initiialized, which can cause wrong driver behavior. Ensure that cached data is current before acting on it. Reported-by: Kevin Folz Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/it87.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -1354,6 +1354,7 @@ static ssize_t set_pwm(struct device *de return -EINVAL; mutex_lock(&data->update_lock); + it87_update_pwm_ctrl(data, nr); if (has_newer_autopwm(data)) { /* * If we are in automatic mode, the PWM duty cycle register @@ -1466,6 +1467,7 @@ static ssize_t set_pwm_temp_map(struct d } mutex_lock(&data->update_lock); + it87_update_pwm_ctrl(data, nr); data->pwm_temp_map[nr] = reg; /* * If we are in automatic mode, write the temp mapping immediately;