diff mbox series

[RFC,net-next,2/6] ptp: Initialize skb_shared_hwtstamps

Message ID 20220306085658.1943-3-gerhard@engleder-embedded.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series ptp: Support hardware clocks with additional free running time | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 14 maintainers not CCed: moyufeng@huawei.com ecree.xilinx@gmail.com dchickles@marvell.com habetsm.xilinx@gmail.com rajur@chelsio.com petrm@nvidia.com fmanlunas@marvell.com tanhuazhong@huawei.com salil.mehta@huawei.com idosch@nvidia.com huangguangbin2@huawei.com sburla@marvell.com dan.carpenter@oracle.com yisen.zhuang@huawei.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 14 this patch: 14
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 49 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Gerhard Engleder March 6, 2022, 8:56 a.m. UTC
There are only a few locations, which do not initialize the whole
skb_shared_hwtstamps structure and write the only field of the
structure. This is ok as long as skb_shared_hwtstamps is not extended
with additional fields.

Always initialize the whole skb_shared_hwtstamps structure to prepare
for future extensions of this structure.

Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c        | 1 +
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c     | 1 +
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c         | 1 +
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c | 1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c     | 1 +
 drivers/net/ethernet/sfc/tx_common.c                   | 1 +
 drivers/ptp/ptp_ines.c                                 | 1 +
 7 files changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index ba28aa444e5a..8c7868007bdf 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -2212,6 +2212,7 @@  static void handle_timestamp(struct octeon_device *oct,
 		netif_info(lio, tx_done, lio->netdev,
 			   "Got resulting SKBTX_HW_TSTAMP skb=%p ns=%016llu\n",
 			   skb, (unsigned long long)ns);
+		memset(&ts, 0, sizeof(ts));
 		ts.hwtstamp = ns_to_ktime(ns + lio->ptp_adjust);
 		skb_tstamp_tx(skb, &ts);
 	}
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 568f211d91cc..ebac2d46a3bf 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -1340,6 +1340,7 @@  static void handle_timestamp(struct octeon_device *oct, u32 status, void *buf)
 		netif_info(lio, tx_done, lio->netdev,
 			   "Got resulting SKBTX_HW_TSTAMP skb=%p ns=%016llu\n",
 			   skb, (unsigned long long)ns);
+		memset(&ts, 0, sizeof(ts));
 		ts.hwtstamp = ns_to_ktime(ns + lio->ptp_adjust);
 		skb_tstamp_tx(skb, &ts);
 	}
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
index 5bf117d2179f..67241dbe575c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c
@@ -109,6 +109,7 @@  void cxgb4_ptp_read_hwstamp(struct adapter *adapter, struct port_info *pi)
 	tx_ts |= (u64)t4_read_reg(adapter,
 				  T5_PORT_REG(pi->port_id,
 					      MAC_PORT_TX_TS_VAL_HI)) << 32;
+	memset(skb_ts, 0, sizeof(*skb_ts));
 	skb_ts->hwtstamp = ns_to_ktime(tx_ts);
 	skb_tstamp_tx(adapter->ptp_tx_skb, skb_ts);
 	dev_kfree_skb_any(adapter->ptp_tx_skb);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
index a40b1583f114..4e378d856529 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ptp.c
@@ -103,6 +103,7 @@  void hclge_ptp_clean_tx_hwts(struct hclge_dev *hdev)
 		hdev->ptp->tx_cleaned++;
 
 		ns += (((u64)hi) << 32 | lo) * NSEC_PER_SEC;
+		memset(&hwts, 0, sizeof(hwts));
 		hwts.hwtstamp = ns_to_ktime(ns);
 		skb_tstamp_tx(skb, &hwts);
 		dev_kfree_skb_any(skb);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
index 35422e64d89f..887a09887f03 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c
@@ -445,6 +445,7 @@  static void mlxsw_sp1_packet_timestamp(struct mlxsw_sp *mlxsw_sp,
 	nsec = timecounter_cyc2time(&mlxsw_sp->clock->tc, timestamp);
 	spin_unlock_bh(&mlxsw_sp->clock->lock);
 
+	memset(&hwtstamps, 0, sizeof(hwtstamps));
 	hwtstamps.hwtstamp = ns_to_ktime(nsec);
 	mlxsw_sp1_ptp_packet_finish(mlxsw_sp, skb,
 				    key.local_port, key.ingress, &hwtstamps);
diff --git a/drivers/net/ethernet/sfc/tx_common.c b/drivers/net/ethernet/sfc/tx_common.c
index d530cde2b864..f7b6228a6be0 100644
--- a/drivers/net/ethernet/sfc/tx_common.c
+++ b/drivers/net/ethernet/sfc/tx_common.c
@@ -170,6 +170,7 @@  void efx_dequeue_buffer(struct efx_tx_queue *tx_queue,
 		     tx_queue->completed_timestamp_minor)) {
 			struct skb_shared_hwtstamps hwtstamp;
 
+			memset(&hwtstamp, 0, sizeof(hwtstamp));
 			hwtstamp.hwtstamp =
 				efx_ptp_nic_to_kernel_time(tx_queue);
 			skb_tstamp_tx(skb, &hwtstamp);
diff --git a/drivers/ptp/ptp_ines.c b/drivers/ptp/ptp_ines.c
index 61f47fb9d997..6413e44267cc 100644
--- a/drivers/ptp/ptp_ines.c
+++ b/drivers/ptp/ptp_ines.c
@@ -659,6 +659,7 @@  static void ines_txtstamp_work(struct work_struct *work)
 		kfree_skb(skb);
 		return;
 	}
+	memset(&ssh, 0, sizeof(ssh));
 	ssh.hwtstamp = ns_to_ktime(ns);
 	skb_complete_tx_timestamp(skb, &ssh);
 }