summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/intel/i40e/i40e_ptp.c
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2014-06-04 08:22:44 +0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2014-06-26 15:45:00 +0400
commitd19af2afe70c11c17552e3290560037a8812f467 (patch)
tree3ca43582227d5604b5d13ef471ee3c8d4b78c8cd /drivers/net/ethernet/intel/i40e/i40e_ptp.c
parent189464555a4aef4db07f90294bd3723079f7c19a (diff)
downloadlinux-d19af2afe70c11c17552e3290560037a8812f467.tar.xz
i40e: don't store user requested mode until we've validated it
This patch prevents the SIOCGHWTSTAMP ioctl from possibly returning bad data, by not permanently storing the setting into the private structure until after we've finished validating that we can support it. Change-ID: Ib59f9b4f73f451d5a2e76fb8efa5d4271b218433 Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_ptp.c')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ptp.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index e5f558c9d7d0..f7dded9976e9 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -549,17 +549,20 @@ static int i40e_ptp_set_timestamp_mode(struct i40e_pf *pf,
**/
int i40e_ptp_set_ts_config(struct i40e_pf *pf, struct ifreq *ifr)
{
- struct hwtstamp_config *config = &pf->tstamp_config;
+ struct hwtstamp_config config;
int err;
- if (copy_from_user(config, ifr->ifr_data, sizeof(*config)))
+ if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
return -EFAULT;
- err = i40e_ptp_set_timestamp_mode(pf, config);
+ err = i40e_ptp_set_timestamp_mode(pf, &config);
if (err)
return err;
- return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
+ /* save these settings for future reference */
+ pf->tstamp_config = config;
+
+ return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-EFAULT : 0;
}