linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold}
@ 2023-03-31  1:06 Yang Li
  2023-04-03 18:24 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Li @ 2023-03-31  1:06 UTC (permalink / raw)
  To: jgg; +Cc: leon, linux-rdma, linux-kernel, Yang Li, Abaci Robot

The call netdev_{put, hold} of dev_{put, hold} will check NULL,
so there is no need to check before using dev_{put, hold},
remove it to silence the warnings:

./drivers/infiniband/core/cma.c:713:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
./drivers/infiniband/core/cma.c:2433:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4668
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 drivers/infiniband/core/cma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 6b9563d4f23c..93a1c48d0c32 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -709,8 +709,7 @@ cma_validate_port(struct ib_device *device, u32 port,
 	}
 
 	sgid_attr = rdma_find_gid_by_port(device, gid, gid_type, port, ndev);
-	if (ndev)
-		dev_put(ndev);
+	dev_put(ndev);
 	return sgid_attr;
 }
 
@@ -2429,8 +2428,7 @@ static int cma_ib_req_handler(struct ib_cm_id *cm_id,
 	mutex_unlock(&listen_id->handler_mutex);
 
 net_dev_put:
-	if (net_dev)
-		dev_put(net_dev);
+	dev_put(net_dev);
 
 	return ret;
 }
-- 
2.20.1.7.g153144c


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

* Re: [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold}
  2023-03-31  1:06 [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold} Yang Li
@ 2023-04-03 18:24 ` Leon Romanovsky
  0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2023-04-03 18:24 UTC (permalink / raw)
  To: jgg, Yang Li; +Cc: linux-rdma, linux-kernel, Abaci Robot


On Fri, 31 Mar 2023 09:06:33 +0800, Yang Li wrote:
> The call netdev_{put, hold} of dev_{put, hold} will check NULL,
> so there is no need to check before using dev_{put, hold},
> remove it to silence the warnings:
> 
> ./drivers/infiniband/core/cma.c:713:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
> ./drivers/infiniband/core/cma.c:2433:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
> 
> [...]

Applied, thanks!

[1/1] RDMA/cma: Remove NULL check before dev_{put, hold}
      https://git.kernel.org/rdma/rdma/c/08ebf57f6e1d73

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

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

* Re: [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold}
  2023-06-14  1:43 Yang Li
@ 2023-06-20 15:51 ` Jason Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2023-06-20 15:51 UTC (permalink / raw)
  To: Yang Li; +Cc: leon, linux-rdma, linux-kernel, Abaci Robot

On Wed, Jun 14, 2023 at 09:43:28AM +0800, Yang Li wrote:
> The call netdev_{put, hold} of dev_{put, hold} will check NULL,
> so there is no need to check before using dev_{put, hold},
> remove it to silence the warning:
> 
> ./drivers/infiniband/core/cma.c:4812:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5521
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
>  drivers/infiniband/core/cma.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied to for-next, thanks

Jason

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

* [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold}
@ 2023-06-14  1:43 Yang Li
  2023-06-20 15:51 ` Jason Gunthorpe
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Li @ 2023-06-14  1:43 UTC (permalink / raw)
  To: leon; +Cc: jgg, linux-rdma, linux-kernel, Yang Li, Abaci Robot

The call netdev_{put, hold} of dev_{put, hold} will check NULL,
so there is no need to check before using dev_{put, hold},
remove it to silence the warning:

./drivers/infiniband/core/cma.c:4812:2-9: WARNING: NULL check before dev_{put, hold} functions is not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5521
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 drivers/infiniband/core/cma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 11643ef7002d..15940bff053c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4808,8 +4808,7 @@ static void cma_make_mc_event(int status, struct rdma_id_private *id_priv,
 	event->param.ud.qkey = id_priv->qkey;
 
 out:
-	if (ndev)
-		dev_put(ndev);
+	dev_put(ndev);
 }
 
 static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
-- 
2.20.1.7.g153144c


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

end of thread, other threads:[~2023-06-20 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31  1:06 [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold} Yang Li
2023-04-03 18:24 ` Leon Romanovsky
2023-06-14  1:43 Yang Li
2023-06-20 15:51 ` Jason Gunthorpe

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).