diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2018-07-12 13:13:24 +0200 |
---|---|---|
committer | Patrick Rudolph <siro@das-labor.org> | 2018-07-17 08:05:13 +0000 |
commit | 239e435739aff51f8e680f75e8130eb3c488901d (patch) | |
tree | 3137b793e191b5a4d1bc4bf4becfb2eb3b779048 /src | |
parent | 4461613119a04f86899a7423658f91b2fe10125b (diff) | |
download | coreboot-239e435739aff51f8e680f75e8130eb3c488901d.tar.xz |
cavium/bdk: Fix possible divide by zero
Fix Coverity CID1393970
Change-Id: I5db6866b8e51eaea201a4c03e59d7d00f4f826e7
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/27453
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vendorcode/cavium/bdk/libbdk-hal/bdk-usb.c | 4 |
1 files changed, 3 insertions, 1 deletions
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"; |