Skip to content

Commit a2df846

Browse files
Tom Rixkuba-moo
authored andcommitted
igc: return an error if the mac type is unknown in igc_ptp_systim_to_hwtstamp()
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: 81b0552 ("igc: Add support for RX timestamping") Signed-off-by: Tom Rix <[email protected]> Reviewed-by: Simon Horman <[email protected]> Acked-by: Sasha Neftin <[email protected]> Tested-by: Naama Meir <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9c6b9cb commit a2df846

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/net/ethernet/intel/igc/igc_ptp.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,12 @@ static int igc_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin,
417417
*
418418
* We need to convert the system time value stored in the RX/TXSTMP registers
419419
* into a hwtstamp which can be used by the upper level timestamping functions.
420+
*
421+
* Returns 0 on success.
420422
**/
421-
static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
422-
struct skb_shared_hwtstamps *hwtstamps,
423-
u64 systim)
423+
static int igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
424+
struct skb_shared_hwtstamps *hwtstamps,
425+
u64 systim)
424426
{
425427
switch (adapter->hw.mac.type) {
426428
case igc_i225:
@@ -430,8 +432,9 @@ static void igc_ptp_systim_to_hwtstamp(struct igc_adapter *adapter,
430432
systim & 0xFFFFFFFF);
431433
break;
432434
default:
433-
break;
435+
return -EINVAL;
434436
}
437+
return 0;
435438
}
436439

437440
/**
@@ -652,7 +655,8 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
652655

653656
regval = rd32(IGC_TXSTMPL);
654657
regval |= (u64)rd32(IGC_TXSTMPH) << 32;
655-
igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval);
658+
if (igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval))
659+
return;
656660

657661
switch (adapter->link_speed) {
658662
case SPEED_10:

0 commit comments

Comments
 (0)