* [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not needed
@ 2022-11-23 9:08 zhang.songyi
2022-11-28 9:50 ` [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not? needed Leon Romanovsky
0 siblings, 1 reply; 3+ messages in thread
From: zhang.songyi @ 2022-11-23 9:08 UTC (permalink / raw)
To: yishaih; +Cc: jgg, leon, linux-rdma, linux-kernel, zhang.songyi
From: zhang songyi <zhang.songyi@zte.com.cn>
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.
Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
---
drivers/infiniband/hw/mlx4/main.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ba47874f90d3..dceebcd885bb 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not? needed
2022-11-23 9:08 [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not needed zhang.songyi
@ 2022-11-28 9:50 ` Leon Romanovsky
0 siblings, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2022-11-28 9:50 UTC (permalink / raw)
To: zhang.songyi; +Cc: yishaih, jgg, linux-rdma, linux-kernel
On Wed, Nov 23, 2022 at 05:08:25PM +0800, zhang.songyi@zte.com.cn wrote:
> From: zhang songyi <zhang.songyi@zte.com.cn>
>
> 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.
>
> Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
> ---
> drivers/infiniband/hw/mlx4/main.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
This patch doesn't apply to rdma-next tree.
Please fix commit title "not?" -> "not" and resubmit.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not needed
@ 2022-11-28 10:58 zhang.songyi
0 siblings, 0 replies; 3+ messages in thread
From: zhang.songyi @ 2022-11-28 10:58 UTC (permalink / raw)
To: leon, yishaih; +Cc: gg, leon, linux-rdma, linux-kernel, zhang.songyi
From: zhang songyi <zhang.songyi@zte.com.cn>
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.
Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
---
drivers/infiniband/hw/mlx4/main.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ba47874f90d3..dceebcd885bb 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-28 10:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 9:08 [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not needed zhang.songyi
2022-11-28 9:50 ` [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not? needed Leon Romanovsky
2022-11-28 10:58 [PATCH linux-next] RDMA/mlx4: NULL check before dev_{put, hold} functions is not needed zhang.songyi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).