Skip to content

Commit 42cd8de

Browse files
gal-pressmankuba-moo
authored andcommitted
net/mlx5: Remove NULL check before dev_{put, hold}
Fix coccinelle warnings: WARNING: NULL check before dev_{put, hold} functions is not needed. Signed-off-by: Gal Pressman <gal@nvidia.com> Reviewed-by: Jianbo Liu <jianbol@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Link: https://patch.msgid.link/1742412199-159596-2-git-send-email-tariqt@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent c3ad9d9 commit 42cd8de

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ static void mlx5e_tc_tun_route_attr_cleanup(struct mlx5e_tc_tun_route_attr *attr
3131
{
3232
if (attr->n)
3333
neigh_release(attr->n);
34-
if (attr->route_dev)
35-
dev_put(attr->route_dev);
34+
dev_put(attr->route_dev);
3635
}
3736

3837
struct mlx5e_tc_tunnel *mlx5e_get_tc_tun(struct net_device *tunnel_dev)
@@ -68,16 +67,14 @@ static int get_route_and_out_devs(struct mlx5e_priv *priv,
6867
* while holding rcu read lock. Take the net_device for correctness
6968
* sake.
7069
*/
71-
if (uplink_upper)
72-
dev_hold(uplink_upper);
70+
dev_hold(uplink_upper);
7371
rcu_read_unlock();
7472

7573
dst_is_lag_dev = (uplink_upper &&
7674
netif_is_lag_master(uplink_upper) &&
7775
real_dev == uplink_upper &&
7876
mlx5_lag_is_sriov(priv->mdev));
79-
if (uplink_upper)
80-
dev_put(uplink_upper);
77+
dev_put(uplink_upper);
8178

8279
/* if the egress device isn't on the same HW e-switch or
8380
* it's a LAG device, use the uplink

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ static int mlx5e_set_int_port_tunnel(struct mlx5e_priv *priv,
4242
&attr->action, out_index);
4343

4444
out:
45-
if (route_dev)
46-
dev_put(route_dev);
45+
dev_put(route_dev);
4746

4847
return err;
4948
}
@@ -753,8 +752,7 @@ static int mlx5e_set_vf_tunnel(struct mlx5_eswitch *esw,
753752
}
754753

755754
out:
756-
if (route_dev)
757-
dev_put(route_dev);
755+
dev_put(route_dev);
758756
return err;
759757
}
760758

@@ -788,8 +786,7 @@ static int mlx5e_update_vf_tunnel(struct mlx5_eswitch *esw,
788786
mlx5e_tc_match_to_reg_mod_hdr_change(esw->dev, mod_hdr_acts, VPORT_TO_REG, act_id, data);
789787

790788
out:
791-
if (route_dev)
792-
dev_put(route_dev);
789+
dev_put(route_dev);
793790
return err;
794791
}
795792

drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,7 @@ static struct net_device *mlx5_lag_active_backup_get_netdev(struct mlx5_core_dev
523523
ndev = ldev->pf[last_idx].netdev;
524524
}
525525

526-
if (ndev)
527-
dev_hold(ndev);
526+
dev_hold(ndev);
528527

529528
unlock:
530529
spin_unlock_irqrestore(&lag_lock, flags);

0 commit comments

Comments
 (0)