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