[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52841F9F.2040907@broadcom.com>
Date: Wed, 13 Nov 2013 16:55:59 -0800
From: "Nithin Nayak Sujir" <nsujir@...adcom.com>
To: "Ben Hutchings" <bhutchings@...arflare.com>,
"David Miller" <davem@...emloft.net>
cc: netdev@...r.kernel.org,
"Richard Cochran" <richardcochran@...il.com>,
"Michael Chan" <mchan@...adcom.com>
Subject: Re: [PATCH net 1/6] tg3: Validate hwtstamp_config completely
before applying it
On 11/13/2013 04:40 PM, Ben Hutchings wrote:
> 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: Ben Hutchings <bhutchings@...arflare.com>
> ---
> drivers/net/ethernet/broadcom/tg3.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 12d961c4ebca..d3a700f86f1a 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -13598,16 +13598,9 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
> if (stmpconf.flags)
> return -EINVAL;
>
> - switch (stmpconf.tx_type) {
> - case HWTSTAMP_TX_ON:
> - tg3_flag_set(tp, TX_TSTAMP_EN);
> - break;
> - case HWTSTAMP_TX_OFF:
> - tg3_flag_clear(tp, TX_TSTAMP_EN);
> - break;
> - default:
> + if (stmpconf.tx_type != HWTSTAMP_TX_ON &&
> + stmpconf.tx_type != HWTSTAMP_TX_OFF)
> return -ERANGE;
> - }
>
> switch (stmpconf.rx_filter) {
> case HWTSTAMP_FILTER_NONE:
> @@ -13669,6 +13662,11 @@ static int tg3_hwtstamp_ioctl(struct net_device *dev,
> tw32(TG3_RX_PTP_CTL,
> 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)) ?
> -EFAULT : 0;
> }
>
>
Thanks Ben.
Acked-by: Nithin Nayak Sujir <nsujir@...adcom.com>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists