soc/nvidia/tegra124: Assert divisor is non-zero

The logic for the calculation of plld.m is rather complicated, so do a
sanity check that it is non-zero before doing the division.

Change-Id: I60f49b8eed47a3de86713304bde7a4d3f3d935dd
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1260981
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34572
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Jacob Garber
2019-07-25 12:06:28 -06:00
committed by Patrick Georgi
parent 321daa86ef
commit 693c55c545

View File

@@ -13,6 +13,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <assert.h>
#include <arch/clock.h> #include <arch/clock.h>
#include <device/mmio.h> #include <device/mmio.h>
#include <console/console.h> #include <console/console.h>
@@ -377,6 +378,7 @@ clock_display(u32 frequency)
printk(BIOS_WARNING, "%s: Failed to match output frequency %u, " printk(BIOS_WARNING, "%s: Failed to match output frequency %u, "
"best difference is %u.\n", __func__, frequency, "best difference is %u.\n", __func__, frequency,
best_diff); best_diff);
assert(plld.m != 0);
rounded_rate = (ref / plld.m * plld.n) >> plld.p; rounded_rate = (ref / plld.m * plld.n) >> plld.p;
} }