From: Wolfram Sang Date: Fri, 8 Apr 2016 11:28:42 +0000 (+0200) Subject: net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0 X-Git-Tag: v4.6-rc5~19^2~39 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a6d37131c02f15463daa00e2f1da6824e8e00de2;p=karo-tx-linux.git net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0 The clk API may return 0 on clk_get_rate, so we should check the result before using it as a divisor. Signed-off-by: Wolfram Sang Acked-by: Sergei Shtylyov Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 087e14a3fba7..9e2a0bd8f5a8 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1691,6 +1691,9 @@ static int ravb_set_gti(struct net_device *ndev) rate = clk_get_rate(clk); clk_put(clk); + if (!rate) + return -EINVAL; + inc = 1000000000ULL << 20; do_div(inc, rate);