Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp479848ybl; Tue, 28 Jan 2020 06:36:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyYIinah1BuQdEzX+Wg+2uhh3ZqiMMvVk/ZNXWGNv+2Mq2I9DV7MVLHTw+4UcXsROGxJTJ1 X-Received: by 2002:aca:3d7:: with SMTP id 206mr3044184oid.98.1580222189734; Tue, 28 Jan 2020 06:36:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222189; cv=none; d=google.com; s=arc-20160816; b=Jb3CcTxV2L/mCbxm7eHQB3ThmeP0ojenBCbvtq+XgmHED6bBg0+rUff/Rwa+pzX5er vNvCP0qwn2mGUImzilJD06IH2+fHFOiCMQVDGvemFE0eNnDO4hT104YUMZ/8VBwX3bPG P8Dvu1wNwhLRby9WVdhGdm32rF76K7PY0pjRjM1WR0rp8uUrhMtpEz+cyR4c5OUc+KXa LpnZZtS2Y4HTCxK11TOv9GKhxpNr5QoZlUElD3bgsVZItgc0NSRoMedZAqWvzEHNS+tL rYz7TfLbVhB3KGe+ctYyuXqv2SFav8XjEnGZFObmljK/IGjRVuX4Y1AKbYu1IGgwiDhQ KWbw== 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=KFRzwoD4GFhreHTQvxQn9bDUDICWa4fA+H/BqK/wDe0=; b=OhAQHLP+HMoSanq4+gQKx9XyeHo/MokpI32hcJ3wk3mbMp3XHtAfw3xf6j/ptYf2Hz IJnarpeN2FA21K5cA2XCbKMecrS3yXKFL3qllZkluHVZxKL62LkfgMu2ZgF8RZavOO7h r738FB6R0SfjX+94PpjUr68m5Gb+BEfwN5yMYMHdehRtuEjK9lC2Lf7tLNj+dmUxF92B AgB//mvf94+w/z8dx6T0uO6BILUD3j+kyhyr1aZ4G/0n0chMUefb6bdaVuUo8B6otqST vxB0TyH0nMHktKuaRB9gCO/PvD0feHtNVXFyynAN+4urbq6+fZVSaKwa1rz6t27KI+F5 GRIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jq9h+kHB; 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 m26si2598500otr.159.2020.01.28.06.36.17; Tue, 28 Jan 2020 06:36:29 -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=Jq9h+kHB; 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 S1733141AbgA1Oe2 (ORCPT + 99 others); Tue, 28 Jan 2020 09:34:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:50606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732472AbgA1OYG (ORCPT ); Tue, 28 Jan 2020 09:24:06 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 0AAE824688; Tue, 28 Jan 2020 14:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221445; bh=9VcWLlPOVrBfmsF+gWhJQIvg/rr++BFkrp5PDDrmsMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jq9h+kHBnUglO6VxBodIx8SQ4EquAFS9czoU8iTNlQ7FVkq0zFtwY5S1qpIOHSlo4 MW8OGfG0nMlq/Mfpgsgl6hCO6id6zub0nSI0XHYnKtq13+5nz+sdRN1G5kmC1XIzN3 Jna3/iEjeIbRYcZHS6kVdGgZfmFRKKpCtUJsH11A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Iker Perez del Palomar Sustatxa , Guenter Roeck , Sasha Levin Subject: [PATCH 4.9 190/271] hwmon: (lm75) Fix write operations for negative temperatures Date: Tue, 28 Jan 2020 15:05:39 +0100 Message-Id: <20200128135906.719278713@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Guenter Roeck [ Upstream commit 7d82fcc9d9e81241778aaa22fda7be753e237d86 ] Writes into limit registers fail if the temperature written is negative. The regmap write operation checks the value range, regmap_write accepts an unsigned int as parameter, and the temperature value passed to regmap_write is kept in a variable declared as long. Negative values are converted large unsigned integers, which fails the range check. Fix by type casting the temperature to u16 when calling regmap_write(). Cc: Iker Perez del Palomar Sustatxa Fixes: e65365fed87f ("hwmon: (lm75) Convert to use regmap") Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/lm75.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index eff3b24d84737..fc31669a86ba8 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -164,7 +164,7 @@ static int lm75_write(struct device *dev, enum hwmon_sensor_types type, temp = DIV_ROUND_CLOSEST(temp << (resolution - 8), 1000) << (16 - resolution); - return regmap_write(data->regmap, reg, temp); + return regmap_write(data->regmap, reg, (u16)temp); } static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type, -- 2.20.1