From: Giuseppe CAVALLARO <peppe.cavallaro@st•com>
To: Ben Hutchings <bhutchings@solarflare•com>,
Rayagond K <rayagond@vayavyalabs•com>
Cc: David Miller <davem@davemloft•net>, <netdev@vger•kernel.org>,
Richard Cochran <richardcochran@gmail•com>
Subject: Re: [PATCH net 4/6] stmmac: Validate hwtstamp_config completely before applying it
Date: Tue, 19 Nov 2013 06:26:07 +0100 [thread overview]
Message-ID: <528AF66F.2060204@st.com> (raw)
In-Reply-To: <1384389821.29151.10.camel@bwh-desktop.uk.level5networks.com>
On 11/14/2013 1:44 AM, Ben Hutchings wrote:
> stmmac_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.
Thx Ben for this patch.
Rayagond, can you do any run-time tests?
peppe
>
> Signed-off-by: Ben Hutchings <bhutchings@solarflare•com>
> ---
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 8d4ccd35a016..8a7a23a84ac5 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -435,16 +435,9 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
> if (config.flags)
> return -EINVAL;
>
> - switch (config.tx_type) {
> - case HWTSTAMP_TX_OFF:
> - priv->hwts_tx_en = 0;
> - break;
> - case HWTSTAMP_TX_ON:
> - priv->hwts_tx_en = 1;
> - break;
> - default:
> + if (config.tx_type != HWTSTAMP_TX_OFF &&
> + config.tx_type != HWTSTAMP_TX_ON)
> return -ERANGE;
> - }
>
> if (priv->adv_ts) {
> switch (config.rx_filter) {
> @@ -576,6 +569,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
> }
> }
> priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1);
> + priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON;
>
> if (!priv->hwts_tx_en && !priv->hwts_rx_en)
> priv->hw->ptp->config_hw_tstamping(priv->ioaddr, 0);
>
>
next prev parent reply other threads:[~2013-11-19 5:26 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
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 [this message]
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=528AF66F.2060204@st.com \
--to=peppe.cavallaro@st$(echo .)com \
--cc=bhutchings@solarflare$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=rayagond@vayavyalabs$(echo .)com \
--cc=richardcochran@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox