Commit 58b187c6 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

tg3: Validate hwtstamp_config completely before applying it

tg3_hwtstamp_ioctl() should validate all fields of hwtstamp_config
before making any changes.  Currently it sets the TX configuration
before validating the rx_filter field.

Compile-tested only.
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Acked-by: default avatarNithin Nayak Sujir <nsujir@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b4e09b29
...@@ -13618,16 +13618,9 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev, ...@@ -13618,16 +13618,9 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
if (stmpconf.flags) if (stmpconf.flags)
return -EINVAL; return -EINVAL;
switch (stmpconf.tx_type) { if (stmpconf.tx_type != HWTSTAMP_TX_ON &&
case HWTSTAMP_TX_ON: stmpconf.tx_type != HWTSTAMP_TX_OFF)
tg3_flag_set(tp, TX_TSTAMP_EN);
break;
case HWTSTAMP_TX_OFF:
tg3_flag_clear(tp, TX_TSTAMP_EN);
break;
default:
return -ERANGE; return -ERANGE;
}
switch (stmpconf.rx_filter) { switch (stmpconf.rx_filter) {
case HWTSTAMP_FILTER_NONE: case HWTSTAMP_FILTER_NONE:
...@@ -13689,6 +13682,11 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev, ...@@ -13689,6 +13682,11 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
tw32(TG3_RX_PTP_CTL, tw32(TG3_RX_PTP_CTL,
tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK); tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK);
if (stmpconf.tx_type == HWTSTAMP_TX_ON)
tg3_flag_set(tp, TX_TSTAMP_EN);
else
tg3_flag_clear(tp, TX_TSTAMP_EN);
return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ? return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
-EFAULT : 0; -EFAULT : 0;
} }
......
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