lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54B990B9.2020702@codeaurora.org>
Date:	Fri, 16 Jan 2015 14:29:13 -0800
From:	Stephen Boyd <sboyd@...eaurora.org>
To:	Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
	Mike Turquette <mturquette@...aro.org>
CC:	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] clk: fractional-divider: prevent division by zero

On 01/16/2015 04:37 AM, Heikki Krogerus wrote:
> Preventing division by zero condition by making sure that
> the initial n and m values are not 0.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> ---
>  drivers/clk/clk-fractional-divider.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c
> index 82a59d0..dc91da7 100644
> --- a/drivers/clk/clk-fractional-divider.c
> +++ b/drivers/clk/clk-fractional-divider.c
> @@ -104,6 +104,7 @@ struct clk *clk_register_fractional_divider(struct device *dev,
>  	struct clk_fractional_divider *fd;
>  	struct clk_init_data init;
>  	struct clk *clk;
> +	u32 val;
>  
>  	fd = kzalloc(sizeof(*fd), GFP_KERNEL);
>  	if (!fd) {
> @@ -126,6 +127,14 @@ struct clk *clk_register_fractional_divider(struct device *dev,
>  	fd->lock = lock;
>  	fd->hw.init = &init;
>  
> +	/* Prevent division by zero */
> +	val = clk_readl(fd->reg);
> +	if (!(val & fd->nmask))
> +		val |= 1 << fd->nshift;
> +	if (!(val & fd->mmask))
> +		val |= 1 << fd->mshift;
> +	clk_writel(val, fd->reg);
> +
>  	clk = clk_register(dev, &fd->hw);
>  	if (IS_ERR(clk))
>  		kfree(fd);

Sorry I don't understand this at all. Does your hardware support a value
of 0 in the register? Doesn't that mean "bypass" so that the rate of the
parent bypasses the divider? If so, why aren't we fixing the
recalc_rate() logic to check for a special case of 0?

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ