Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933830AbbBDM1Z (ORCPT ); Wed, 4 Feb 2015 07:27:25 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:48633 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933738AbbBDM1X (ORCPT ); Wed, 4 Feb 2015 07:27:23 -0500 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1069 Lines: 34 Anyone may call clk_round_rate() with a zero rate value, so we have to protect against that. Signed-off-by: Geert Uytterhoeven --- 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); } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/