From fd4c0db89e94f936e2603e175611f34d0ffa4bb1 Mon Sep 17 00:00:00 2001 From: Avinash Repaka Date: Fri, 21 Oct 2016 15:34:19 -0700 Subject: [PATCH] RDS: IB: Destroy rdma_cm_id when unloading module rdma_cm_id is not being destroyed as part of module_exit(). This would lead to memory corruption and eventual node crash if rds_rdma module is unloaded. To avoid this, stop listening(destroy rdma_cm_id) as the first step of unloading the module and curb any more connection attempts. This undoes the change made by commit 4d4692145bf7 ("RDS: Drop stale iWARP support") Orabug: 26089296 Signed-off-by: Avinash Repaka Reviewed-by: Yuval Shaia --- net/rds/rdma_transport.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c index 1cd260a0f8f9..2d673a1e09c3 100644 --- a/net/rds/rdma_transport.c +++ b/net/rds/rdma_transport.c @@ -44,6 +44,8 @@ #define RDS_REJ_CONSUMER_DEFINED 28 +static struct rdma_cm_id *rds_rdma_listen_id; + int unload_allowed __initdata; module_param_named(module_unload_allowed, unload_allowed, int, 0); @@ -385,6 +387,7 @@ static int rds_rdma_listen_init(void) rdsdebug("cm %p listening on port %u\n", cm_id, RDS_PORT); + rds_rdma_listen_id = cm_id; cm_id = NULL; out: if (cm_id) @@ -392,6 +395,15 @@ out: return ret; } +static void rds_rdma_listen_stop(void) +{ + if (rds_rdma_listen_id) { + rdsdebug("cm %p\n", rds_rdma_listen_id); + rdma_destroy_id(rds_rdma_listen_id); + rds_rdma_listen_id = NULL; + } +} + #define MODULE_NAME "rds_rdma" int __init rds_rdma_init(void) @@ -427,6 +439,8 @@ module_init(rds_rdma_init); void rds_rdma_exit(void) { + /* stop listening first to ensure no new connections are attempted */ + rds_rdma_listen_stop(); /* cancel initial ib failover work if still active*/ cancel_delayed_work_sync(&riif_dlywork); rds_ib_exit(); -- 2.50.1