2023-03-31 01:09:00

by Yang Li

[permalink] [raw]
Subject: [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold}

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 <[email protected]>
Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4668
Signed-off-by: Yang Li <[email protected]>
---
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


2023-04-03 18:29:19

by Leon Romanovsky

[permalink] [raw]
Subject: Re: [PATCH -next] RDMA/cma: Remove NULL check before dev_{put, hold}


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 <[email protected]>