]> www.infradead.org Git - users/hch/misc.git/commitdiff
net/mlx5: Remove NULL check before dev_{put, hold}
authorGal Pressman <gal@nvidia.com>
Wed, 19 Mar 2025 19:23:17 +0000 (21:23 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 24 Mar 2025 20:45:57 +0000 (13:45 -0700)
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>
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c

index 721f35e5975795e052b00ff2b8852d49ab04bb57..2162d776fe35de11d2716cbf66f211e7cb11f869 100644 (file)
@@ -31,8 +31,7 @@ static void mlx5e_tc_tun_route_attr_cleanup(struct mlx5e_tc_tun_route_attr *attr
 {
        if (attr->n)
                neigh_release(attr->n);
-       if (attr->route_dev)
-               dev_put(attr->route_dev);
+       dev_put(attr->route_dev);
 }
 
 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,
         * 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
index e7e01f3298efb0c78e83e85a52062dcd8a2864a0..a0fc76a1bc0820cd504feb67ce0abb4f1fbbbfbf 100644 (file)
@@ -42,8 +42,7 @@ static int mlx5e_set_int_port_tunnel(struct mlx5e_priv *priv,
                                                &attr->action, out_index);
 
 out:
-       if (route_dev)
-               dev_put(route_dev);
+       dev_put(route_dev);
 
        return err;
 }
@@ -753,8 +752,7 @@ static int mlx5e_set_vf_tunnel(struct mlx5_eswitch *esw,
        }
 
 out:
-       if (route_dev)
-               dev_put(route_dev);
+       dev_put(route_dev);
        return err;
 }
 
@@ -788,8 +786,7 @@ static int mlx5e_update_vf_tunnel(struct mlx5_eswitch *esw,
        mlx5e_tc_match_to_reg_mod_hdr_change(esw->dev, mod_hdr_acts, VPORT_TO_REG, act_id, data);
 
 out:
-       if (route_dev)
-               dev_put(route_dev);
+       dev_put(route_dev);
        return err;
 }
 
index ed2ba272946b9d72f6a51d7c7ec3a10f1a423e1c..ba41dd149f53cd0adddce4daa4e0f895580c8052 100644 (file)
@@ -523,8 +523,7 @@ static struct net_device *mlx5_lag_active_backup_get_netdev(struct mlx5_core_dev
                ndev = ldev->pf[last_idx].netdev;
        }
 
-       if (ndev)
-               dev_hold(ndev);
+       dev_hold(ndev);
 
 unlock:
        spin_unlock_irqrestore(&lag_lock, flags);