diff options
author | Jisheng Zhang <jszhang@marvell.com> | 2015-12-15 17:25:27 +0300 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2015-12-27 23:04:50 +0300 |
commit | 3024e0d13b0f34536f94bf0d7cc11443beeee9c5 (patch) | |
tree | ac821866889cf44a9e06917322331995c9af775b /drivers/watchdog/diag288_wdt.c | |
parent | 5889f06bd31d542766046faa6b17d957c08e1484 (diff) | |
download | linux-3024e0d13b0f34536f94bf0d7cc11443beeee9c5.tar.xz |
watchdog: dw_wdt: fix signedness bug in dw_wdt_top_in_seconds()
On 64bit platforms, "(1 << (16 + top)) / clk_get_rate(dw_wdt.clk)" is
sign-extended to 64bit then converted to unsigned 64bit, finally divide
the clk rate. If the top is the maximum TOP i.e 15, "(1 << (16 +15))"
will be sign-extended to 0xffffffff80000000, then converted to unsigned
0xffffffff80000000, which is a huge number, thus the final result is
wrong.
We fix this issue by giving usigned value(1U in this case) at first.
Let's assume clk rate is 25MHZ,
Before the patch:
dw_wdt_top_in_seconds(15) = -864612050
After the patch:
dw_wdt_top_in_seconds(15) = 85
Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/diag288_wdt.c')
0 files changed, 0 insertions, 0 deletions