Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Neftin, Sasha" <sasha.neftin@intel.com>
To: Tom Rix <trix@redhat.com>, <jesse.brandeburg@intel.com>,
	<anthony.l.nguyen@intel.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<richardcochran@gmail.com>, <nathan@kernel.org>,
	<ndesaulniers@google.com>, <vinicius.gomes@intel.com>,
	<jeffrey.t.kirsher@intel.com>
Cc: netdev@vger.kernel.org, llvm@lists.linux.dev,
	intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH] igc: return an error if the mac type is unknown in igc_ptp_systim_to_hwtstamp()
Date: Wed, 18 Jan 2023 07:24:30 +0200	[thread overview]
Message-ID: <d1088f1a-d9d2-68c9-ca2f-cf314f057aba@intel.com> (raw)
In-Reply-To: <20230114140412.3975245-1-trix@redhat.com>

On 1/14/2023 16:04, Tom Rix wrote:
> clang static analysis reports
> drivers/net/ethernet/intel/igc/igc_ptp.c:673:3: warning: The left operand of
>    '+' is a garbage value [core.UndefinedBinaryOperatorResult]
>     ktime_add_ns(shhwtstamps.hwtstamp, adjust);
>     ^            ~~~~~~~~~~~~~~~~~~~~
> 
> igc_ptp_systim_to_hwtstamp() silently returns without setting the hwtstamp
> if the mac type is unknown.  This should be treated as an error.
> 
> Fixes: 81b055205e8b ("igc: Add support for RX timestamping")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>   drivers/net/ethernet/intel/igc/igc_ptp.c | 14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igc/igc_ptp.c b/drivers/net/ethernet/intel/igc/igc_ptp.c
> index c34734d432e0..4e10ced736db 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ptp.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ptp.c
> @@ -417,10 +417,12 @@ static int igc_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin,
>    *
>    * We need to convert the system time value stored in the RX/TXSTMP registers
>    * into a hwtstamp which can be used by the upper level timestamping functions.
> + *
> + * Returns 0 on success.
>    **/
> -static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
> -				       struct skb_shared_hwtstamps *hwtstamps,
> -				       u64 systim)
> +static int igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
> +				      struct skb_shared_hwtstamps *hwtstamps,
> +				      u64 systim)
>   {
>   	switch (adapter->hw.mac.type) {
>   	case igc_i225:
> @@ -430,8 +432,9 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
>   						systim & 0xFFFFFFFF);
>   		break;
>   	default:
> -		break;
> +		return -EINVAL;
>   	}
> +	return 0;
>   }
>   
>   /**
> @@ -652,7 +655,8 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
>   
>   	regval = rd32(IGC_TXSTMPL);
>   	regval |= (u64)rd32(IGC_TXSTMPH) << 32;
> -	igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval);
> +	if (igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval))
> +		return;
>   
>   	switch (adapter->link_speed) {
>   	case SPEED_10:
Acked-by: Sasha Neftin <sasha.neftin@intel.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

  parent reply	other threads:[~2023-01-18  5:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14 14:04 [Intel-wired-lan] [PATCH] igc: return an error if the mac type is unknown in igc_ptp_systim_to_hwtstamp() Tom Rix
2023-01-15 18:03 ` Simon Horman
2023-01-18  5:24 ` Neftin, Sasha [this message]
2023-01-23 11:15 ` naamax.meir

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=d1088f1a-d9d2-68c9-ca2f-cf314f057aba@intel.com \
    --to=sasha.neftin@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=trix@redhat.com \
    --cc=vinicius.gomes@intel.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