Commit d5d5fd8f authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: move copy_from_user() out of net_hwtstamp_validate()

The kernel will want to start using the more meaningful struct
hwtstamp_config pointer in more places, so move the copy_from_user() at
the beginning of dev_set_hwtstamp() in order to get to that, and pass
this argument to net_hwtstamp_validate().
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4ee58e1e
...@@ -183,22 +183,18 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm ...@@ -183,22 +183,18 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm
return err; return err;
} }
static int net_hwtstamp_validate(struct ifreq *ifr) static int net_hwtstamp_validate(const struct hwtstamp_config *cfg)
{ {
struct hwtstamp_config cfg;
enum hwtstamp_tx_types tx_type; enum hwtstamp_tx_types tx_type;
enum hwtstamp_rx_filters rx_filter; enum hwtstamp_rx_filters rx_filter;
int tx_type_valid = 0; int tx_type_valid = 0;
int rx_filter_valid = 0; int rx_filter_valid = 0;
if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg))) if (cfg->flags & ~HWTSTAMP_FLAG_MASK)
return -EFAULT;
if (cfg.flags & ~HWTSTAMP_FLAG_MASK)
return -EINVAL; return -EINVAL;
tx_type = cfg.tx_type; tx_type = cfg->tx_type;
rx_filter = cfg.rx_filter; rx_filter = cfg->rx_filter;
switch (tx_type) { switch (tx_type) {
case HWTSTAMP_TX_OFF: case HWTSTAMP_TX_OFF:
...@@ -263,9 +259,13 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr) ...@@ -263,9 +259,13 @@ static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)
static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr) static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
{ {
struct hwtstamp_config cfg;
int err; int err;
err = net_hwtstamp_validate(ifr); if (copy_from_user(&cfg, ifr->ifr_data, sizeof(cfg)))
return -EFAULT;
err = net_hwtstamp_validate(&cfg);
if (err) if (err)
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment