Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756802AbcCCEZK (ORCPT ); Wed, 2 Mar 2016 23:25:10 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:49034 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752728AbcCCEZH (ORCPT ); Wed, 2 Mar 2016 23:25:07 -0500 Date: Wed, 2 Mar 2016 20:25:05 -0800 From: Guenter Roeck To: Wolfram Sang Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Wim Van Sebroeck , linux-watchdog@vger.kernel.org Subject: Re: [PATCH 5/6] watchdog: atlas7_wdt: test clock rate to avoid division by 0 Message-ID: <20160303042505.GA4578@roeck-us.net> References: <1456958018-7849-1-git-send-email-wsa@the-dreams.de> <1456958018-7849-6-git-send-email-wsa@the-dreams.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456958018-7849-6-git-send-email-wsa@the-dreams.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1053 Lines: 36 On Wed, Mar 02, 2016 at 11:33:36PM +0100, Wolfram Sang wrote: > 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 Reviewed-by: Guenter Roeck > --- > > Should go individually via subsystem tree. > > drivers/watchdog/atlas7_wdt.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/watchdog/atlas7_wdt.c b/drivers/watchdog/atlas7_wdt.c > index df6d9242a31958..ed80734befae16 100644 > --- a/drivers/watchdog/atlas7_wdt.c > +++ b/drivers/watchdog/atlas7_wdt.c > @@ -154,6 +154,11 @@ static int atlas7_wdt_probe(struct platform_device *pdev) > writel(0, wdt->base + ATLAS7_WDT_CNT_CTRL); > > wdt->tick_rate = clk_get_rate(clk); > + if (!wdt->tick_rate) { > + ret = -EINVAL; > + goto err1; > + } > + > wdt->clk = clk; > atlas7_wdd.min_timeout = 1; > atlas7_wdd.max_timeout = UINT_MAX / wdt->tick_rate; > -- > 2.7.0 >