From patchwork Wed Feb 4 12:27:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 5776311 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF315BF440 for ; Wed, 4 Feb 2015 12:27:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1858520154 for ; Wed, 4 Feb 2015 12:27:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 458A12014A for ; Wed, 4 Feb 2015 12:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933744AbbBDM1Y (ORCPT ); Wed, 4 Feb 2015 07:27:24 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:48634 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933492AbbBDM1X (ORCPT ); Wed, 4 Feb 2015 07:27:23 -0500 Received: from ayla.of.borg ([84.193.93.87]) by andre.telenet-ops.be with bizsmtp id oCTN1p00n1t5w8s01CTNP4; Wed, 04 Feb 2015 13:27:22 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1YIz3C-0006ej-EH; Wed, 04 Feb 2015 13:27:22 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1YIz3E-0003xg-Kp; Wed, 04 Feb 2015 13:27:24 +0100 From: Geert Uytterhoeven To: Mike Turquette , Stephen Boyd Cc: Laurent Pinchart , Ulrich Hecht , Wolfram Sang , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] clk: shmobile: div6: Avoid division by zero in .round_rate() Date: Wed, 4 Feb 2015 13:27:21 +0100 Message-Id: <1423052841-15194-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Anyone may call clk_round_rate() with a zero rate value, so we have to protect against that. Signed-off-by: Geert Uytterhoeven Acked-by: Wolfram Sang --- This was triggered by the bad version of "clk: Add rate constraints to clocks", but can happen regardless, cfr. https://lkml.org/lkml/2015/1/29/560 drivers/clk/shmobile/clk-div6.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/shmobile/clk-div6.c b/drivers/clk/shmobile/clk-div6.c index efbaf6c81b7530b8..036a692c72195db9 100644 --- a/drivers/clk/shmobile/clk-div6.c +++ b/drivers/clk/shmobile/clk-div6.c @@ -90,6 +90,9 @@ static unsigned int cpg_div6_clock_calc_div(unsigned long rate, { unsigned int div; + if (!rate) + rate = 1; + div = DIV_ROUND_CLOSEST(parent_rate, rate); return clamp_t(unsigned int, div, 1, 64); }