Skip to content

Commit

Permalink
net: stmmac: Fixed mtu channged by cache aligned
Browse files Browse the repository at this point in the history
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: eaf4fac ("net: stmmac: Do not accept invalid MTU values")
Signed-off-by: David Wu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
SuperDavidWu authored and kuba-moo committed Jan 14, 2021
1 parent 8ad2a97 commit 5b55299
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4026,6 +4026,7 @@ 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;
const int mtu = new_mtu;

if (txfifosz == 0)
txfifosz = priv->dma_cap.tx_fifo_size;
Expand All @@ -4043,7 +4044,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);

Expand Down

0 comments on commit 5b55299

Please sign in to comment.