From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752660AbdHNPh4 (ORCPT ); Mon, 14 Aug 2017 11:37:56 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:33189 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbdHNPhy (ORCPT ); Mon, 14 Aug 2017 11:37:54 -0400 Date: Mon, 14 Aug 2017 08:37:52 -0700 From: Guenter Roeck To: Huibin Hong Cc: wim@iguana.be, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: Re: [PATCH] watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds Message-ID: <20170814153752.GB7025@roeck-us.net> References: <1501159843-6623-1-git-send-email-huibin.hong@rock-chips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1501159843-6623-1-git-send-email-huibin.hong@rock-chips.com> User-Agent: Mutt/1.5.24 (2015-08-30) 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 27, 2017 at 08:50:43PM +0800, Huibin Hong wrote: > If top is 15, (1 << (16 + top)) may be negative. > > Change-Id: I76e4a603a54f093e64a4b266008570e3afcdb35a No Change-Id in upstream patches, please. > Signed-off-by: Huibin Hong I am having trouble applying this patch. What is its baseline version ? Guenter > --- > drivers/watchdog/dw_wdt.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c > index 6ea0634..059c974 100644 > --- a/drivers/watchdog/dw_wdt.c > +++ b/drivers/watchdog/dw_wdt.c > @@ -81,7 +81,9 @@ static inline int dw_wdt_top_in_seconds(unsigned top) > * There are 16 possible timeout values in 0..15 where the number of > * cycles is 2 ^ (16 + i) and the watchdog counts down. > */ > - return (1 << (16 + top)) / clk_get_rate(dw_wdt.clk); > + unsigned int cycles = 1 << (16 + top); > + > + return cycles / clk_get_rate(dw_wdt.clk); > } > > static int dw_wdt_get_top(void) > -- > 1.9.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html