Skip to contentSkip to conversation

be2net: bug fix in be_change_mtu

PATCH Applied Ajit Khaparde 2 participants 2 messages Feb 9, 2010 – Feb 12, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/7 be2net: bug fix in be_change_mtu

Current code allows the new mtu to cross the supported value. This patch fixes the boundary checks.

From: Suresh R <[email protected]>

---
 drivers/net/benet/be_main.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/benet/be_main.c +4 -2
index 1d773db..f1136a3 100644
@@ -473,10 +473,12 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	struct be_adapter *adapter = netdev_priv(netdev);
 	if (new_mtu < BE_MIN_MTU ||
-			new_mtu > BE_MAX_JUMBO_FRAME_SIZE) {
+			new_mtu > (BE_MAX_JUMBO_FRAME_SIZE -
+					(ETH_HLEN + ETH_FCS_LEN))) {
 		dev_info(&adapter->pdev->dev,
 			"MTU must be between %d and %d bytes\n",
-			BE_MIN_MTU, BE_MAX_JUMBO_FRAME_SIZE);
+			BE_MIN_MTU,
+			(BE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN)));
 		return -EINVAL;
 	}
 	dev_info(&adapter->pdev->dev, "MTU changed from %d to %d bytes\n",
Signature · 1 line
1.6.3.3