netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: richardcochran@gmail.com, yangbo.lu@nxp.com, davem@davemloft.net,
	kuba@kernel.org
Cc: mlichvar@redhat.com, vinicius.gomes@intel.com,
	netdev@vger.kernel.org,
	Gerhard Engleder <gerhard@engleder-embedded.com>
Subject: [RFC PATCH net-next 2/6] ptp: Initialize skb_shared_hwtstamps
Date: Sun,  6 Mar 2022 09:56:54 +0100	[thread overview]
Message-ID: <20220306085658.1943-3-gerhard@engleder-embedded.com> (raw)
In-Reply-To: <20220306085658.1943-1-gerhard@engleder-embedded.com>

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 --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);
 }
-- 
2.20.1


  parent reply	other threads:[~2022-03-06  8:57 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-06  8:56 [RFC PATCH net-next 0/6] ptp: Support hardware clocks with additional free running time Gerhard Engleder
2022-03-06  8:56 ` [RFC PATCH net-next 1/6] bpf: Access hwtstamp field of hwtstamps directly Gerhard Engleder
2022-03-06  8:56 ` Gerhard Engleder [this message]
2022-03-06  8:56 ` [RFC PATCH net-next 3/6] ptp: Add free running time support Gerhard Engleder
2022-03-06 16:36   ` Richard Cochran
2022-03-06  8:56 ` [RFC PATCH net-next 4/6] ptp: Support time stamps based on free running time Gerhard Engleder
2022-03-06 16:42   ` Richard Cochran
2022-03-06  8:56 ` [RFC PATCH net-next 5/6] ptp: Allow vclocks without free running physical clock Gerhard Engleder
2022-03-06  8:56 ` [RFC PATCH net-next 6/6] tsnep: Add free running time support Gerhard Engleder
2022-03-06 16:49 ` [RFC PATCH net-next 0/6] ptp: Support hardware clocks with additional free running time Richard Cochran
2022-03-06 16:53   ` Richard Cochran
2022-03-06 17:05 ` Richard Cochran
2022-03-06 18:38   ` Gerhard Engleder
2022-03-06 21:50     ` Richard Cochran
2022-03-07 14:34       ` Richard Cochran
2022-03-07 17:54         ` Gerhard Engleder
2022-03-07 21:30           ` Richard Cochran
2022-03-08  0:55           ` Richard Cochran
2022-03-08 19:49             ` Gerhard Engleder
2022-03-08 20:52               ` Richard Cochran
2022-03-08  0:57           ` Richard Cochran
2022-03-07 12:07 ` Michael Walle
2022-03-07 14:05   ` Richard Cochran
2022-03-07 14:23     ` Miroslav Lichvar
2022-03-07 14:37       ` Richard Cochran
2022-03-08 20:55         ` Richard Cochran
2022-03-07 16:01   ` Gerhard Engleder

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=20220306085658.1943-3-gerhard@engleder-embedded.com \
    --to=gerhard@engleder-embedded.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=vinicius.gomes@intel.com \
    --cc=yangbo.lu@nxp.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).