提交 c9f441ee 编写于 作者: T Tom Rix 提交者: zhaoxiaoqiang11

igc: return an error if the mac type is unknown in igc_ptp_systim_to_hwtstamp()

stable inclusion
from stable-v5.10.168
commit 6362b861704fbf7d331bba35407927d9cd84eb9b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6362b861704fbf7d331bba35407927d9cd84eb9b

----------------------------------------------------

[ Upstream commit a2df8463 ]

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: 81b05520 ("igc: Add support for RX timestamping")
Signed-off-by: NTom Rix <trix@redhat.com>
Reviewed-by: NSimon Horman <simon.horman@corigine.com>
Acked-by: NSasha Neftin <sasha.neftin@intel.com>
Tested-by: NNaama Meir <naamax.meir@linux.intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
Link: https://lore.kernel.org/r/20230131215437.1528994-1-anthony.l.nguyen@intel.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
上级 78d87e68
...@@ -134,10 +134,12 @@ static int igc_ptp_feature_enable_i225(struct ptp_clock_info *ptp, ...@@ -134,10 +134,12 @@ static int igc_ptp_feature_enable_i225(struct ptp_clock_info *ptp,
* *
* We need to convert the system time value stored in the RX/TXSTMP registers * 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. * 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, static int igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
struct skb_shared_hwtstamps *hwtstamps, struct skb_shared_hwtstamps *hwtstamps,
u64 systim) u64 systim)
{ {
switch (adapter->hw.mac.type) { switch (adapter->hw.mac.type) {
case igc_i225: case igc_i225:
...@@ -147,8 +149,9 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter, ...@@ -147,8 +149,9 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
systim & 0xFFFFFFFF); systim & 0xFFFFFFFF);
break; break;
default: default:
break; return -EINVAL;
} }
return 0;
} }
/** /**
...@@ -372,7 +375,8 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter) ...@@ -372,7 +375,8 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
regval = rd32(IGC_TXSTMPL); regval = rd32(IGC_TXSTMPL);
regval |= (u64)rd32(IGC_TXSTMPH) << 32; 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) { switch (adapter->link_speed) {
case SPEED_10: case SPEED_10:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册