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] [day] [month] [year] [list]
Message-ID: <87a6vlspe5.fsf@kurt>
Date:   Fri, 13 Nov 2020 08:10:42 +0100
From:   Kurt Kanzenbach <kurt.kanzenbach@...utronix.de>
To:     YueHaibing <yuehaibing@...wei.com>, olteanv@...il.com,
        andrew@...n.ch, vivien.didelot@...il.com, f.fainelli@...il.com,
        davem@...emloft.net, kuba@...nel.org
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        YueHaibing <yuehaibing@...wei.com>,
        Richard Cochran <richardcochran@...il.com>
Subject: Re: [PATCH] net: dsa: sja1105: Fix return value check in sja1105_ptp_clock_register()

On Thu Nov 12 2020, YueHaibing wrote:
> drivers/net/dsa/sja1105/sja1105_ptp.c:869 sja1105_ptp_clock_register() warn: passing zero to 'PTR_ERR'
>
> ptp_clock_register() returns ERR_PTR() and never returns
> NULL. The NULL test should be removed.

Which is not true. From the documentation:

 * Returns a valid pointer on success or PTR_ERR on failure.  If PHC
 * support is missing at the configuration level, this function
 * returns NULL, and drivers are expected to gracefully handle that
 * case separately.

Please, always Cc Richard for PTP patches.

Actually you can have a look at this discussion here:

 https://lkml.kernel.org/netdev/1605086686-5140-1-git-send-email-wangqing@vivo.com/

>
> Fixes: bb77f36ac21d ("net: dsa: sja1105: Add support for the PTP clock")
> Signed-off-by: YueHaibing <yuehaibing@...wei.com>
> ---
>  drivers/net/dsa/sja1105/sja1105_ptp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
> index 1b90570b257b..1e41d491c854 100644
> --- a/drivers/net/dsa/sja1105/sja1105_ptp.c
> +++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
> @@ -865,7 +865,7 @@ int sja1105_ptp_clock_register(struct dsa_switch *ds)
>  	spin_lock_init(&tagger_data->meta_lock);
>  
>  	ptp_data->clock = ptp_clock_register(&ptp_data->caps, ds->dev);
> -	if (IS_ERR_OR_NULL(ptp_data->clock))
> +	if (IS_ERR(ptp_data->clock))

When you do this, you'll have to make sure that the driver handles the
NULL case "gracefully".

Thanks,
Kurt

Download attachment "signature.asc" of type "application/pgp-signature" (833 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ