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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Sun, 6 Mar 2016 10:09:52 +0100
From:	Wim Van Sebroeck <wim@...ana.be>
To:	Wolfram Sang <wsa@...-dreams.de>
Cc:	linux-kernel@...r.kernel.org, Guenter Roeck <linux@...ck-us.net>,
	linux-watchdog@...r.kernel.org
Subject: Re: [PATCH v2] watchdog: tangox_wdt: test clock rate to avoid division by 0

Hi Wolfram,

> From: Wolfram Sang <wsa+renesas@...g-engineering.com>
> 
> The clk API may return 0 on clk_get_rate, so we should check the result before
> using it as a divisor. For this, refactor the code to use a central
> error path.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@...g-engineering.com>
> ---
>  drivers/watchdog/tangox_wdt.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/watchdog/tangox_wdt.c b/drivers/watchdog/tangox_wdt.c
> index 709c1ed6fd79b9..cfbed7e051b619 100644
> --- a/drivers/watchdog/tangox_wdt.c
> +++ b/drivers/watchdog/tangox_wdt.c
> @@ -139,6 +139,10 @@ static int tangox_wdt_probe(struct platform_device *pdev)
>  		return err;
>  
>  	dev->clk_rate = clk_get_rate(dev->clk);
> +	if (!dev->clk_rate) {
> +		err = -EINVAL;
> +		goto err;
> +	}
>  
>  	dev->wdt.parent = &pdev->dev;
>  	dev->wdt.info = &tangox_wdt_info;
> @@ -171,10 +175,8 @@ static int tangox_wdt_probe(struct platform_device *pdev)
>  	}
>  
>  	err = watchdog_register_device(&dev->wdt);
> -	if (err) {
> -		clk_disable_unprepare(dev->clk);
> -		return err;
> -	}
> +	if (err)
> +		goto err;
>  
>  	platform_set_drvdata(pdev, dev);
>  
> @@ -187,6 +189,10 @@ static int tangox_wdt_probe(struct platform_device *pdev)
>  	dev_info(&pdev->dev, "SMP86xx/SMP87xx watchdog registered\n");
>  
>  	return 0;
> +
> + err:
> +	clk_disable_unprepare(dev->clk);
> +	return err;
>  }
>  
>  static int tangox_wdt_remove(struct platform_device *pdev)
> -- 
> 2.7.0
> 

Patch has been added to linux-watchdog-next.

Kind regards,
Wim.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ