@@ -131,7 +131,7 @@ static inline struct ucma_context *_ucma_find_context(int id,
131
131
ctx = idr_find (& ctx_idr , id );
132
132
if (!ctx )
133
133
ctx = ERR_PTR (- ENOENT );
134
- else if (ctx -> file != file )
134
+ else if (ctx -> file != file || ! ctx -> cm_id )
135
135
ctx = ERR_PTR (- EINVAL );
136
136
return ctx ;
137
137
}
@@ -453,6 +453,7 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
453
453
struct rdma_ucm_create_id cmd ;
454
454
struct rdma_ucm_create_id_resp resp ;
455
455
struct ucma_context * ctx ;
456
+ struct rdma_cm_id * cm_id ;
456
457
enum ib_qp_type qp_type ;
457
458
int ret ;
458
459
@@ -473,10 +474,10 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
473
474
return - ENOMEM ;
474
475
475
476
ctx -> uid = cmd .uid ;
476
- ctx -> cm_id = rdma_create_id (current -> nsproxy -> net_ns ,
477
- ucma_event_handler , ctx , cmd .ps , qp_type );
478
- if (IS_ERR (ctx -> cm_id )) {
479
- ret = PTR_ERR (ctx -> cm_id );
477
+ cm_id = rdma_create_id (current -> nsproxy -> net_ns ,
478
+ ucma_event_handler , ctx , cmd .ps , qp_type );
479
+ if (IS_ERR (cm_id )) {
480
+ ret = PTR_ERR (cm_id );
480
481
goto err1 ;
481
482
}
482
483
@@ -486,10 +487,12 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
486
487
ret = - EFAULT ;
487
488
goto err2 ;
488
489
}
490
+
491
+ ctx -> cm_id = cm_id ;
489
492
return 0 ;
490
493
491
494
err2 :
492
- rdma_destroy_id (ctx -> cm_id );
495
+ rdma_destroy_id (cm_id );
493
496
err1 :
494
497
mutex_lock (& mut );
495
498
idr_remove (& ctx_idr , ctx -> id );
0 commit comments