net/mlx5e: Remove NULL check before dev_{put, hold}
Subsystems (3)
PATCH 1/1 net/mlx5e: Remove NULL check before dev_{put, hold}
Coccinelle reports a warning
WARNING: NULL check before dev_{put, hold} functions is not needed
The reason is the call netdev_{put, hold} of dev_{put,hold} will check NULL There is no need to check before using dev_{put, hold}
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +2 -4
@@ -68,16 +68,14 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,* while holding rcu read lock. Take the net_device for correctness * sake. */ -if (uplink_upper) -dev_hold (uplink_upper); +dev_hold (uplink_upper);rcu_read_unlock (); dst_is_lag_dev = (uplink_upper &&netif_is_lag_master (uplink_upper) && real_dev == uplink_upper &&mlx5_lag_is_sriov (priv->mdev)); -if (uplink_upper) -dev_put (uplink_upper); +dev_put (uplink_upper);/* if the egress device isn't on the same HW e-switch or * it's a LAG device, use the uplink
Signature · 1 line
2.43.2
Quoted 17 lines · Jules Irenge
Coccinelle reports a warning
WARNING: NULL check before dev_{put, hold} functions is not needed
The reason is the call netdev_{put, hold} of dev_{put,hold} will check NULL There is no need to check before using dev_{put, hold}
Signed-off-by Jules Irenge <[email protected]>--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +0
-0
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c static int get_route_and_out_devs(struct mlx5e_priv *priv, · line 71
Quoted 6 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +1
-2@@ -68,16 +68,14 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,* while holding rcu read lock. Take the net_device for correctness * sake. */ -if (uplink_upper) -dev_hold (uplink_upper); +dev_hold (uplink_upper);
I see same if (..) dev_hold() in drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c too.
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c static int get_route_and_out_devs(struct mlx5e_priv *priv, · line 78
Quoted 9 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +1
-2rcu_read_unlock (); dst_is_lag_dev = (uplink_upper &&netif_is_lag_master (uplink_upper) && real_dev == uplink_upper &&mlx5_lag_is_sriov (priv->mdev)); -if (uplink_upper) -dev_put (uplink_upper); +dev_put (uplink_upper);
This pattern exists in other places in the same file and others too.
Let's change all of them in one patch.
Thanks
Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +0
-0/* if the egress device isn't on the same HW e-switch or * it's a LAG device, use the uplink Signature · 1 line
2.43.2