netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Fixed mtu channged by cache aligned
@ 2021-01-13  3:41 David Wu
  2021-01-14  4:11 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: David Wu @ 2021-01-13  3:41 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, joabreu, alexandre.torgue, peppe.cavallaro,
	linux-kernel, David Wu

Since the original mtu is not used when the mtu is updated,
the mtu is aligned with cache, this will get an incorrect.
For example, if you want to configure the mtu to be 1500,
but mtu 1536 is configured in fact.

Fixed: eaf4fac478077 ("net: stmmac: Do not accept invalid MTU values")
Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 5b1c12ff98c0..e8640123db76 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4025,7 +4025,7 @@ static void stmmac_set_rx_mode(struct net_device *dev)
 static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
-	int txfifosz = priv->plat->tx_fifo_size;
+	int txfifosz = priv->plat->tx_fifo_size, mtu = new_mtu;
 
 	if (txfifosz == 0)
 		txfifosz = priv->dma_cap.tx_fifo_size;
@@ -4043,7 +4043,7 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
 	if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB))
 		return -EINVAL;
 
-	dev->mtu = new_mtu;
+	dev->mtu = mtu;
 
 	netdev_update_features(dev);
 
-- 
2.19.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: stmmac: Fixed mtu channged by cache aligned
  2021-01-13  3:41 [PATCH] net: stmmac: Fixed mtu channged by cache aligned David Wu
@ 2021-01-14  4:11 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2021-01-14  4:11 UTC (permalink / raw)
  To: David Wu
  Cc: netdev, davem, joabreu, alexandre.torgue, peppe.cavallaro, linux-kernel

On Wed, 13 Jan 2021 11:41:09 +0800 David Wu wrote:
> Since the original mtu is not used when the mtu is updated,
> the mtu is aligned with cache, this will get an incorrect.
> For example, if you want to configure the mtu to be 1500,
> but mtu 1536 is configured in fact.
> 
> Fixed: eaf4fac478077 ("net: stmmac: Do not accept invalid MTU values")
> Signed-off-by: David Wu <david.wu@rock-chips.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 5b1c12ff98c0..e8640123db76 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -4025,7 +4025,7 @@ static void stmmac_set_rx_mode(struct net_device *dev)
>  static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
>  {
>  	struct stmmac_priv *priv = netdev_priv(dev);
> -	int txfifosz = priv->plat->tx_fifo_size;
> +	int txfifosz = priv->plat->tx_fifo_size, mtu = new_mtu;

Adjusted the code a little here to keep the variable declaration lines
ordered longest to shortest, and applied. 

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-14  4:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  3:41 [PATCH] net: stmmac: Fixed mtu channged by cache aligned David Wu
2021-01-14  4:11 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).