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: <20210616102038.GB22278@shell.armlinux.org.uk>
Date:   Wed, 16 Jun 2021 11:20:38 +0100
From:   "Russell King (Oracle)" <linux@...linux.org.uk>
To:     Joakim Zhang <qiangqing.zhang@....com>
Cc:     davem@...emloft.net, kuba@...nel.org, peppe.cavallaro@...com,
        alexandre.torgue@...s.st.com, joabreu@...opsys.com,
        mcoquelin.stm32@...il.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        linux-stm32@...md-mailman.stormreply.com,
        linux-arm-kernel@...ts.infradead.org, linux-imx@....com
Subject: Re: [PATCH net 1/2] net: fec_ptp: add clock rate zero check

On Wed, Jun 16, 2021 at 05:14:25PM +0800, Joakim Zhang wrote:
> From: Fugang Duan <fugang.duan@....com>
> 
> Add clock rate zero check to fix coverity issue of "divide by 0".
> 
> Fixes: commit 85bd1798b24a ("net: fec: fix spin_lock dead lock")
> Signed-off-by: Fugang Duan <fugang.duan@....com>
> Signed-off-by: Joakim Zhang <qiangqing.zhang@....com>
> ---
>  drivers/net/ethernet/freescale/fec_ptp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
> index 1753807cbf97..7326a0612823 100644
> --- a/drivers/net/ethernet/freescale/fec_ptp.c
> +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> @@ -604,6 +604,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
>  	fep->ptp_caps.enable = fec_ptp_enable;
>  
>  	fep->cycle_speed = clk_get_rate(fep->clk_ptp);
> +	if (!fep->cycle_speed) {
> +		fep->cycle_speed = NSEC_PER_SEC;
> +		dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n");

If this is supposed to be an error message, it doesn't convey that
something is really wrong to the user. Maybe something like this would
be more meaningful to the user:

	"PTP clock rate should not be zero, using 1GHz instead. PTP
	clock may be unreliable.\n"

It may be appropriate not to publish PTP support for the interface if
we don't have a valid clock rate, which is probably the safer approach
and would probably make the problem more noticable to the end user so
it gets fixed.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ