提交 a6d37131 编写于 作者: W Wolfram Sang 提交者: David S. Miller

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: NWolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: NSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 60e19518
...@@ -1691,6 +1691,9 @@ static int ravb_set_gti(struct net_device *ndev) ...@@ -1691,6 +1691,9 @@ static int ravb_set_gti(struct net_device *ndev)
rate = clk_get_rate(clk); rate = clk_get_rate(clk);
clk_put(clk); clk_put(clk);
if (!rate)
return -EINVAL;
inc = 1000000000ULL << 20; inc = 1000000000ULL << 20;
do_div(inc, rate); do_div(inc, rate);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册