From: Roel Kluin <12o3l@tiscali.nl> Date: Fri, 18 Jan 2008 22:24:01 +0000 (-0800) Subject: possible div by 0 in X-Git-Tag: v2.6.24-omap1~52 X-Git-Url: http://pilppa.org/gitweb/?a=commitdiff_plain;h=ce3d08691cb4d0d1751ac00a4a072cdac38c79c5;p=linux-2.6-omap-h63xx.git possible div by 0 in clk_get_rate may return 0, prevent division by 0 and unobfuscate Signed-off-by: Roel Kluin <12o3l@tiscali.nl> Signed-off-by: Tony Lindgren --- diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index da7409e2e73..a992b167a24 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -94,8 +94,17 @@ u32 gpmc_cs_read_reg(int cs, int idx) /* TODO: Add support for gpmc_fck to clock framework and use it */ unsigned long gpmc_get_fclk_period(void) { - /* In picoseconds */ - return 1000000000 / ((clk_get_rate(gpmc_l3_clk)) / 1000); + unsigned long rate = clk_get_rate(gpmc_l3_clk); + + if (rate == 0) { + printk(KERN_WARNING "gpmc_l3_clk no enabled\n"); + return 0; + } + + rate /= 1000; + rate = 1000000000 / rate; /* In picoseconds */ + + return rate; } unsigned int gpmc_ns_to_ticks(unsigned int time_ns)