netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kurt Kanzenbach <kurt.kanzenbach@linutronix.de>
To: YueHaibing <yuehaibing@huawei.com>,
	olteanv@gmail.com, andrew@lunn.ch, vivien.didelot@gmail.com,
	f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	YueHaibing <yuehaibing@huawei.com>,
	Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH] net: dsa: sja1105: Fix return value check in sja1105_ptp_clock_register()
Date: Fri, 13 Nov 2020 08:10:42 +0100	[thread overview]
Message-ID: <87a6vlspe5.fsf@kurt> (raw)
In-Reply-To: <20201112145532.38320-1-yuehaibing@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]

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@huawei.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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

      reply	other threads:[~2020-11-13  7:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 14:55 [PATCH] net: dsa: sja1105: Fix return value check in sja1105_ptp_clock_register() YueHaibing
2020-11-13  7:10 ` Kurt Kanzenbach [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6vlspe5.fsf@kurt \
    --to=kurt.kanzenbach@linutronix.de \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=richardcochran@gmail.com \
    --cc=vivien.didelot@gmail.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).