* [PATCH v2 -next] infiniband: core: Delete useless kfree code
@ 2020-12-16 8:02 Zheng Yongjun
2021-01-07 18:30 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2020-12-16 8:02 UTC (permalink / raw)
To: leon, linux-rdma, linux-kernel, dledford; +Cc: Zheng Yongjun
The parameter of kfree function is NULL, so kfree code is useless, delete it.
Therefore, goto expression is no longer needed, so simplify it.
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/infiniband/core/cma_configfs.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
index 7ec4af2ed87a..51f59ed6916b 100644
--- a/drivers/infiniband/core/cma_configfs.c
+++ b/drivers/infiniband/core/cma_configfs.c
@@ -202,7 +202,6 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group,
unsigned int i;
unsigned int ports_num;
struct cma_dev_port_group *ports;
- int err;
ibdev = cma_get_ib_dev(cma_dev);
@@ -214,8 +213,8 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group,
GFP_KERNEL);
if (!ports) {
- err = -ENOMEM;
- goto free;
+ cma_dev_group->ports = NULL;
+ return -ENOMEM;
}
for (i = 0; i < ports_num; i++) {
@@ -234,10 +233,6 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group,
cma_dev_group->ports = ports;
return 0;
-free:
- kfree(ports);
- cma_dev_group->ports = NULL;
- return err;
}
static void release_cma_dev(struct config_item *item)
--
2.22.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 -next] infiniband: core: Delete useless kfree code
2020-12-16 8:02 [PATCH v2 -next] infiniband: core: Delete useless kfree code Zheng Yongjun
@ 2021-01-07 18:30 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-01-07 18:30 UTC (permalink / raw)
To: Zheng Yongjun; +Cc: leon, linux-rdma, linux-kernel, dledford
On Wed, Dec 16, 2020 at 04:02:19PM +0800, Zheng Yongjun wrote:
> The parameter of kfree function is NULL, so kfree code is useless, delete it.
> Therefore, goto expression is no longer needed, so simplify it.
>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> drivers/infiniband/core/cma_configfs.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
> index 7ec4af2ed87a..51f59ed6916b 100644
> +++ b/drivers/infiniband/core/cma_configfs.c
> @@ -202,7 +202,6 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group,
> unsigned int i;
> unsigned int ports_num;
> struct cma_dev_port_group *ports;
> - int err;
>
> ibdev = cma_get_ib_dev(cma_dev);
>
> @@ -214,8 +213,8 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group,
> GFP_KERNEL);
>
> if (!ports) {
> - err = -ENOMEM;
> - goto free;
> + cma_dev_group->ports = NULL;
This set is also useless, the only caller allocated cma_dev_group with
kzalloc so it is already NULL here, I fixed it and applied to
for-next, thanks
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-07 18:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 8:02 [PATCH v2 -next] infiniband: core: Delete useless kfree code Zheng Yongjun
2021-01-07 18:30 ` Jason Gunthorpe
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.