* [PATCH] watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds
@ 2017-07-27 12:50 Huibin Hong
2017-08-14 15:37 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Huibin Hong @ 2017-07-27 12:50 UTC (permalink / raw)
To: wim; +Cc: linux-watchdog, linux-kernel, linux-rockchip, Huibin Hong
If top is 15, (1 << (16 + top)) may be negative.
Change-Id: I76e4a603a54f093e64a4b266008570e3afcdb35a
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds
2017-07-27 12:50 [PATCH] watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds Huibin Hong
@ 2017-08-14 15:37 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2017-08-14 15:37 UTC (permalink / raw)
To: Huibin Hong; +Cc: wim, linux-watchdog, linux-kernel, linux-rockchip
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 <huibin.hong@rock-chips.com>
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-14 15:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-27 12:50 [PATCH] watchdog: dw_wdt: fix overflow issue in dw_wdt_top_in_seconds Huibin Hong
2017-08-14 15:37 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®