Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755995AbcCBWdv (ORCPT ); Wed, 2 Mar 2016 17:33:51 -0500 Received: from sauhun.de ([89.238.76.85]:37214 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755557AbcCBWdr (ORCPT ); Wed, 2 Mar 2016 17:33:47 -0500 From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Sergei Shtylyov , netdev@vger.kernel.org Subject: [PATCH 2/6] net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0 Date: Wed, 2 Mar 2016 23:33:33 +0100 Message-Id: <1456958018-7849-3-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456958018-7849-1-git-send-email-wsa@the-dreams.de> References: <1456958018-7849-1-git-send-email-wsa@the-dreams.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 802 Lines: 29 From: Wolfram Sang 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 --- Should go individually via subsystem tree. 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 88656ceb6e2946..ce1954a6a12726 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