From patchwork Mon Dec 5 04:55:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9460335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D1276022E for ; Mon, 5 Dec 2016 06:04:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C9C24B5B for ; Mon, 5 Dec 2016 06:04:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 288692621D; Mon, 5 Dec 2016 06:04:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DADB224B5B for ; Mon, 5 Dec 2016 06:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751176AbcLEGEd (ORCPT ); Mon, 5 Dec 2016 01:04:33 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:51633 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751039AbcLEGEd (ORCPT ); Mon, 5 Dec 2016 01:04:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=5hJ9IWds6nOVrWqaPsP1srASKXXUV/JgaFWJqzrIIVc=; b=ONQ71Hi1pgxyrG IIGEUiW/Kx82eDRTrJ1uW+YzyrzPzzf7BPXaaq2Ug82RYEgLQ50AwxnJICBXtyk9/m8mdjgAgm06r cIr/SOcNN86UkhXdG5ic9eN0VTsiA3ASWxkFWrnLz1CZWkzK2JV8tQlpkoM40cdp6idGMHzm+5i72 3A8uvFuZzY7CviLYNV4byFpEJ0Nu4ZP2EBJL0A5KhVX/MK7sVpOfXPvKDH3cr8TJbyemkqEc8TLv2 tAntcdBKbqasz2LDcsuIgt5eHWAz5izigmKdtjqtnvTUuyqwXKrMvkweDbSbBNQNz3UeZCCS5TZF5 rJsnqb9ONvaKoot7INyw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:49770 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cDlJl-0009Wk-9c; Mon, 05 Dec 2016 04:55:57 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 10/17] hwmon: (lm87) Fix overflow seen when writing voltage limit attributes Date: Sun, 4 Dec 2016 20:55:33 -0800 Message-Id: <1480913740-5678-10-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1480913740-5678-1-git-send-email-linux@roeck-us.net> References: <1480913740-5678-1-git-send-email-linux@roeck-us.net> X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Writes into voltage limit attributes can overflow due to an unbound multiplication. Signed-off-by: Guenter Roeck Reviewed-by: Jean Delvare --- drivers/hwmon/lm87.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index a5e295826aea..24f971b75e46 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -121,7 +121,7 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C }; #define IN_FROM_REG(reg, scale) (((reg) * (scale) + 96) / 192) #define IN_TO_REG(val, scale) ((val) <= 0 ? 0 : \ - (val) * 192 >= (scale) * 255 ? 255 : \ + (val) >= (scale) * 255 / 192 ? 255 : \ ((val) * 192 + (scale) / 2) / (scale)) #define TEMP_FROM_REG(reg) ((reg) * 1000)