From 239e435739aff51f8e680f75e8130eb3c488901d Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 12 Jul 2018 13:13:24 +0200 Subject: cavium/bdk: Fix possible divide by zero Fix Coverity CID1393970 Change-Id: I5db6866b8e51eaea201a4c03e59d7d00f4f826e7 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/27453 Tested-by: build bot (Jenkins) Reviewed-by: Philipp Deppenwiese --- src/vendorcode/cavium/bdk/libbdk-hal/bdk-usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/vendorcode') diff --git a/src/vendorcode/cavium/bdk/libbdk-hal/bdk-usb.c b/src/vendorcode/cavium/bdk/libbdk-hal/bdk-usb.c index eb2a85fa0d..83ce563601 100644 --- a/src/vendorcode/cavium/bdk/libbdk-hal/bdk-usb.c +++ b/src/vendorcode/cavium/bdk/libbdk-hal/bdk-usb.c @@ -369,7 +369,9 @@ int bdk_usb_initialize(bdk_node_t node, int usb_port, bdk_usb_clock_t clock_type uint64_t fr_div; if (divider < 5) fr_div = divider * 2; else fr_div = 8 * (divider - 3); - uint64_t freq = (typeof(freq)) (sclk_rate / fr_div); + uint64_t freq = 0; + if (fr_div > 0) + freq = (typeof(freq)) (sclk_rate / fr_div); const char *token; if (freq < 62500000ULL) token = "???Low"; else if (freq < 90000000ULL) token = "USB2"; -- cgit v1.2.3