All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Nithin Nayak Sujir" <nsujir@broadcom.com>
To: "Ben Hutchings" <bhutchings@solarflare.com>,
	"David Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org,
	"Richard Cochran" <richardcochran@gmail.com>,
	"Michael Chan" <mchan@broadcom.com>
Subject: Re: [PATCH net 1/6] tg3: Validate hwtstamp_config completely before applying it
Date: Wed, 13 Nov 2013 16:55:59 -0800	[thread overview]
Message-ID: <52841F9F.2040907@broadcom.com> (raw)
In-Reply-To: <1384389656.29151.7.camel@bwh-desktop.uk.level5networks.com>



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@solarflare.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@broadcom.com>

  reply	other threads:[~2013-11-14  0:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14  0:39 [PATCH net 0/6] net_tstamp: Validate hwtstamp_config completely before applying it Ben Hutchings
2013-11-14  0:40 ` [PATCH net 1/6] tg3: " Ben Hutchings
2013-11-14  0:55   ` Nithin Nayak Sujir [this message]
2013-11-14  0:41 ` [PATCH net 2/6] e1000e: " Ben Hutchings
2013-11-14 16:36   ` [E1000-devel] " Jeff Kirsher
2013-11-14  0:42 ` [PATCH net 3/6] pch_gbe: " Ben Hutchings
2013-11-14  7:21   ` Richard Cochran
2013-11-14  7:27     ` Richard Cochran
2013-11-14  8:17     ` David Miller
2013-11-14  0:43 ` [PATCH net 4/6] stmmac: " Ben Hutchings
2013-11-19  5:26   ` Giuseppe CAVALLARO
2013-11-19  5:55     ` Rayagond K
2013-11-14  0:47 ` [PATCH net 5/6] ti_cpsw: " Ben Hutchings
2013-11-14 12:49   ` Mugunthan V N
2013-11-14  0:48 ` [PATCH net 6/6] ixp4xx_eth: " Ben Hutchings
2013-11-14  6:53 ` [PATCH net 0/6] net_tstamp: " David Miller
2013-11-14 13:26 ` Richard Cochran
2013-11-14 21:23 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52841F9F.2040907@broadcom.com \
    --to=nsujir@broadcom.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=mchan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.