All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/mlx5: Remove NULL check before dev_{put, hold}
@ 2024-04-30 23:46 Jules Irenge
  2024-05-02 14:46 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Jules Irenge @ 2024-04-30 23:46 UTC (permalink / raw
  To: leon; +Cc: jgg, linux-kernel, linux-rdma, lishifeng, gustavoars

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 <jbi.octave@gmail.com>
---
 drivers/infiniband/hw/mlx5/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index c2b557e64290..2366c46eebc8 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -264,8 +264,7 @@ static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
 	 */
 	read_lock(&ibdev->port[port_num - 1].roce.netdev_lock);
 	ndev = ibdev->port[port_num - 1].roce.netdev;
-	if (ndev)
-		dev_hold(ndev);
+	dev_hold(ndev);
 	read_unlock(&ibdev->port[port_num - 1].roce.netdev_lock);
 
 out:
-- 
2.43.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] RDMA/mlx5: Remove NULL check before dev_{put, hold}
  2024-04-30 23:46 [PATCH] RDMA/mlx5: Remove NULL check before dev_{put, hold} Jules Irenge
@ 2024-05-02 14:46 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2024-05-02 14:46 UTC (permalink / raw
  To: Jules Irenge; +Cc: jgg, linux-kernel, linux-rdma, lishifeng, gustavoars


On Wed, 01 May 2024 00:46:42 +0100, Jules Irenge wrote:
> 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}
> 
> [...]

Applied, thanks!

[1/1] RDMA/mlx5: Remove NULL check before dev_{put, hold}
      https://git.kernel.org/rdma/rdma/c/82e966130ddd67

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-02 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 23:46 [PATCH] RDMA/mlx5: Remove NULL check before dev_{put, hold} Jules Irenge
2024-05-02 14:46 ` Leon Romanovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.