RDMA/mlx4: remove NULL check before dev_{put, hold}
Subsystems (2)
PATCH 1/1 RDMA/mlx4: remove NULL check before dev_{put, hold}
From: zhang songyi <[email protected]>
The call netdev_{put, hold} of dev_{put, hold} will check NULL, so there is no need to check before using dev_{put, hold}.
Fix the following coccicheck warnings:
/drivers/infiniband/hw/mlx4/main.c:1311:2-10: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed.
/drivers/infiniband/hw/mlx4/main.c:148:2-10: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed.
/drivers/infiniband/hw/mlx4/main.c:1959:3-11: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed.
/drivers/infiniband/hw/mlx4/main.c:1962:3-10: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed.
--- drivers/infiniband/hw/mlx4/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/infiniband/hw/mlx4/main.c +4 -8
@@ -144,8 +144,7 @@ static struct net_device *mlx4_ib_get_netdev(struct ib_device *device, } } } -if (dev) -dev_hold (dev); +dev_hold (dev);rcu_read_unlock ();return dev;
@@ -1307,8 +1306,7 @@ int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,spin_lock_bh (&mdev->iboe.lock); ndev = mdev->iboe.netdevs[mqp->port -1 ]; -if (ndev) -dev_hold (ndev); +dev_hold (ndev);spin_unlock_bh (&mdev->iboe.lock);if (ndev) {
@@ -1955,11 +1953,9 @@ static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)if (ge) {spin_lock_bh (&mdev->iboe.lock); ndev = ge->added ? mdev->iboe.netdevs[ge->port -1 ] :NULL ; -if (ndev) -dev_hold (ndev); +dev_hold (ndev);spin_unlock_bh (&mdev->iboe.lock); -if (ndev) -dev_put (ndev); +dev_put (ndev);list_del (&ge->list);kfree (ge); }else
--
2.15.2
Quoted 15 lines · On Mon, Nov 28, 2022 at 08:00:29PM +0800, [email protected] wrote:
From: zhang songyi <[email protected]>
The call netdev_{put, hold} of dev_{put, hold} will check NULL, so there is no need to check before using dev_{put, hold}.
Fix the following coccicheck warnings:
/drivers/infiniband/hw/mlx4/main.c:1311:2-10: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed./drivers/infiniband/hw/mlx4/main.c:148:2-10: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed./drivers/infiniband/hw/mlx4/main.c:1959:3-11: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed.
Quoted 8 lines
/drivers/infiniband/hw/mlx4/main.c:1962:3-10: WARNING:
WARNING NULL check before dev_{put, hold} functions is not needed.Signed-off-by zhang songyi <[email protected]>--- drivers/infiniband/hw/mlx4/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
The patch needs to be based on this repository:
https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git/
branch: for-next
Thanks