]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tegra: clock: Avoid a divide-by-zero error
authorSimon Glass <sjg@chromium.org>
Wed, 31 May 2017 23:57:22 +0000 (17:57 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 9 Jun 2017 19:39:33 +0000 (13:39 -0600)
The clock fix-up for tegra is still present in the code. It causes a
divide-by-zero bug after relocation when chain-loading U-Boot from
coreboot. Fix this by adding a check.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 7468676 (ARM: tegra: fix clock_get_periph_rate() for UART clocks)
arch/arm/mach-tegra/clock.c

index 76436d8d9112473d3c791bae4cab238fa9e31eee..bac42119cdc52a7bda81a8c550f093b80c528f47 100644 (file)
@@ -339,8 +339,11 @@ unsigned long clock_get_periph_rate(enum periph_id periph_id,
                 * return value doesn't help. In summary this clock driver is
                 * quite broken but I'm afraid I have no idea how to fix it
                 * without completely replacing it.
+                *
+                * Be careful to avoid a divide by zero error.
                 */
-               div -= 2;
+               if (div >= 1)
+                       div -= 2;
                break;
 #endif
        default: