From patchwork Fri Apr 8 11:28:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 8782991 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 571C39FBEA for ; Fri, 8 Apr 2016 11:29:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91A352027D for ; Fri, 8 Apr 2016 11:29:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38880201CD for ; Fri, 8 Apr 2016 11:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758219AbcDHL26 (ORCPT ); Fri, 8 Apr 2016 07:28:58 -0400 Received: from sauhun.de ([89.238.76.85]:57124 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756567AbcDHL26 (ORCPT ); Fri, 8 Apr 2016 07:28:58 -0400 Received: from p4fe257c7.dip0.t-ipconnect.de ([79.226.87.199]:40084 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1aoUar-0007GC-TQ; Fri, 08 Apr 2016 13:28:54 +0200 From: Wolfram Sang To: netdev@vger.kernel.org Cc: Wolfram Sang , linux-renesas-soc@vger.kernel.org, David Miller , Sergei Shtylyov Subject: [PATCH RESEND] net: ethernet: renesas: ravb_main: test clock rate to avoid division by 0 Date: Fri, 8 Apr 2016 13:28:42 +0200 Message-Id: <1460114922-4148-1-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.7.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Sergei Shtylyov --- 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);