提交 d19af2af 编写于 作者: J Jacob Keller 提交者: Jeff Kirsher

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: NJacob Keller <jacob.e.keller@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 18946455
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册