2021-07-23 14:10:50

by Leon Romanovsky

[permalink] [raw]
Subject: [PATCH rdma-next 0/3] Remove not possible checks

From: Leon Romanovsky <[email protected]>

The iwpm is part of iw_cm module load, it ensures that iwpm is valid
prior to execution of any commands.

This series deletes such checks.

Thanks

Leon Romanovsky (3):
RDMA/iwcm: Release resources if iw_cm module initialization fails
RDMA/iwpm: Remove not-needed reference counting
RDMA/iwpm: Rely on the upper to ensure that requests are valid

drivers/infiniband/core/iwcm.c | 19 ++++---
drivers/infiniband/core/iwpm_msg.c | 34 +------------
drivers/infiniband/core/iwpm_util.c | 78 ++++++-----------------------
drivers/infiniband/core/iwpm_util.h | 18 -------
4 files changed, 28 insertions(+), 121 deletions(-)

--
2.31.1


2021-07-23 14:13:56

by Leon Romanovsky

[permalink] [raw]
Subject: [PATCH rdma-next 1/3] RDMA/iwcm: Release resources if iw_cm module initialization fails

From: Leon Romanovsky <[email protected]>

The failure during iw_cm module initialization partially left the system
with unreleased memory and other resources. Rewrite the module init/exit
routines in such way that netlink commands will be opened only after
successful initialization.

Fixes: b493d91d333e ("iwcm: common code for port mapper")
Signed-off-by: Leon Romanovsky <[email protected]>
---
drivers/infiniband/core/iwcm.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 42261152b489..2b47073c61a6 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -1186,29 +1186,34 @@ static int __init iw_cm_init(void)

ret = iwpm_init(RDMA_NL_IWCM);
if (ret)
- pr_err("iw_cm: couldn't init iwpm\n");
- else
- rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
+ return ret;
+
iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", 0);
if (!iwcm_wq)
- return -ENOMEM;
+ goto err_alloc;

iwcm_ctl_table_hdr = register_net_sysctl(&init_net, "net/iw_cm",
iwcm_ctl_table);
if (!iwcm_ctl_table_hdr) {
pr_err("iw_cm: couldn't register sysctl paths\n");
- destroy_workqueue(iwcm_wq);
- return -ENOMEM;
+ goto err_sysctl;
}

+ rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
return 0;
+
+err_sysctl:
+ destroy_workqueue(iwcm_wq);
+err_alloc:
+ iwpm_exit(RDMA_NL_IWCM);
+ return -ENOMEM;
}

static void __exit iw_cm_cleanup(void)
{
+ rdma_nl_unregister(RDMA_NL_IWCM);
unregister_net_sysctl_table(iwcm_ctl_table_hdr);
destroy_workqueue(iwcm_wq);
- rdma_nl_unregister(RDMA_NL_IWCM);
iwpm_exit(RDMA_NL_IWCM);
}

--
2.31.1

2021-07-30 14:11:11

by Jason Gunthorpe

[permalink] [raw]
Subject: Re: [PATCH rdma-next 0/3] Remove not possible checks

On Fri, Jul 23, 2021 at 05:08:54PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <[email protected]>
>
> The iwpm is part of iw_cm module load, it ensures that iwpm is valid
> prior to execution of any commands.
>
> This series deletes such checks.
>
> Thanks
>
> Leon Romanovsky (3):
> RDMA/iwcm: Release resources if iw_cm module initialization fails
> RDMA/iwpm: Remove not-needed reference counting
> RDMA/iwpm: Rely on the upper to ensure that requests are valid

Applied to for-next, thanks

Jason