Skip to contentSkip to conversation

net: fec: validate the new settings in fec_enet_set_coalesce()

PATCH In review Jakub Kicinski 3 participants 3 messages Mar 11, 2020 – Mar 12, 2020

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: fec: validate the new settings in fec_enet_set_coalesce()

fec_enet_set_coalesce() validates the previously set params and if they are within range proceeds to apply the new ones. The new ones, however, are not validated. This seems backwards, probably a copy-paste error?

Compile tested only.

Fixes d851b47b22fc ("net: fec: add interrupt coalescence feature support")
---
 drivers/net/ethernet/freescale/fec_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +3 -3
index 4432a59904c7..23c5fef2f1ad 100644
@@ -2529,15 +2529,15 @@ fec_enet_set_coalesce(struct net_device *ndev, struct ethtool_coalesce *ec)
 		return -EINVAL;
 	}
 
-	cycle = fec_enet_us_to_itr_clock(ndev, fep->rx_time_itr);
+	cycle = fec_enet_us_to_itr_clock(ndev, ec->rx_coalesce_usecs);
 	if (cycle > 0xFFFF) {
 		dev_err(dev, "Rx coalesced usec exceed hardware limitation\n");
 		return -EINVAL;
 	}
 
-	cycle = fec_enet_us_to_itr_clock(ndev, fep->tx_time_itr);
+	cycle = fec_enet_us_to_itr_clock(ndev, ec->tx_coalesce_usecs);
 	if (cycle > 0xFFFF) {
-		dev_err(dev, "Rx coalesced usec exceed hardware limitation\n");
+		dev_err(dev, "Tx coalesced usec exceed hardware limitation\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.24.1
Acked-by on v1 1/1
#1 lore raw

From: [email protected] <[email protected]> On Behalf Of Jakub Kicinski

Quoted 9 lines

fec_enet_set_coalesce() validates the previously set params and if they are within range proceeds to apply the new ones.
The new ones, however, are not validated. This seems backwards, probably a copy-paste error?

Compile tested only.

Fixes d851b47b22fc ("net: fec: add interrupt coalescence feature support")

Good catch, parameters range checking doesn't impact function, so it should be copy-paste error.

Quoted 34 lines
---
 drivers/net/ethernet/freescale/fec_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +4 -4
index 4432a59904c7..23c5fef2f1ad 100644
@@ -2529,15 +2529,15 @@ fec_enet_set_coalesce(struct net_device *ndev,
 struct ethtool_coalesce *ec)
                return -EINVAL;
        }
 
-       cycle = fec_enet_us_to_itr_clock(ndev, fep->rx_time_itr);
+       cycle = fec_enet_us_to_itr_clock(ndev, ec->rx_coalesce_usecs);
        if (cycle > 0xFFFF) {
                dev_err(dev, "Rx coalesced usec exceed hardware
 limitation\n");
                return -EINVAL;
        }
 
-       cycle = fec_enet_us_to_itr_clock(ndev, fep->tx_time_itr);
+       cycle = fec_enet_us_to_itr_clock(ndev, ec->tx_coalesce_usecs);
        if (cycle > 0xFFFF) {
-               dev_err(dev, "Rx coalesced usec exceed hardware
 limitation\n");
+               dev_err(dev, "Tx coalesced usec exceed hardware
+ limitation\n");
                return -EINVAL;
        }
 
--

2.24.1

maintainer
#2 lore raw
In reply to Jakub Kicinski

From: Jakub Kicinski <[email protected]>
Date: Tue, 10 Mar 2020 20:36:16 -0700

Quoted 9 lines

fec_enet_set_coalesce() validates the previously set params and if they are within range proceeds to apply the new ones. The new ones, however, are not validated. This seems backwards, probably a copy-paste error?

Compile tested only.

Fixes d851b47b22fc ("net: fec: add interrupt coalescence feature support")

Applied and queued up for -stable, thanks.