netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0
@ 2016-04-08 11:28 Wolfram Sang
  2016-04-14  2:43 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2016-04-08 11:28 UTC (permalink / raw)
  To: netdev; +Cc: Wolfram Sang, linux-renesas-soc, David Miller, Sergei Shtylyov

From: Wolfram Sang <wsa+renesas@sang-engineering.com>

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 <wsa+renesas@sang-engineering.com>
Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---

The original patch was marked as "NOT APPLICABLE" in patchwork. I reviewed
again and can't see why. So, in case this remains true, please explain.

 drivers/net/ethernet/renesas/ravb_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 4e1a7dba7c4abb..791930b63991dc 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);
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RESEND] net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0
  2016-04-08 11:28 [PATCH RESEND] net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0 Wolfram Sang
@ 2016-04-14  2:43 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-04-14  2:43 UTC (permalink / raw)
  To: wsa; +Cc: netdev, linux-renesas-soc, sergei.shtylyov

From: Wolfram Sang <wsa@the-dreams.de>
Date: Fri,  8 Apr 2016 13:28:42 +0200

> From: Wolfram Sang <wsa+renesas@sang-engineering.com>
> 
> 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 <wsa+renesas@sang-engineering.com>
> Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-14  2:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-08 11:28 [PATCH RESEND] net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0 Wolfram Sang
2016-04-14  2:43 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).