@@ -367,20 +367,12 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
367367 int in_len , int out_len )
368368{
369369 struct ib_uverbs_dealloc_pd cmd ;
370- struct ib_uobject * uobj ;
371- int ret ;
372370
373371 if (copy_from_user (& cmd , buf , sizeof cmd ))
374372 return - EFAULT ;
375373
376- uobj = uobj_get_write (UVERBS_OBJECT_PD , cmd .pd_handle ,
377- file -> ucontext );
378- if (IS_ERR (uobj ))
379- return PTR_ERR (uobj );
380-
381- ret = uobj_remove_commit (uobj );
382-
383- return ret ?: in_len ;
374+ return uobj_perform_destroy (UVERBS_OBJECT_PD , cmd .pd_handle , file ,
375+ in_len );
384376}
385377
386378struct xrcd_table_entry {
@@ -597,19 +589,12 @@ ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file,
597589 int out_len )
598590{
599591 struct ib_uverbs_close_xrcd cmd ;
600- struct ib_uobject * uobj ;
601- int ret = 0 ;
602592
603593 if (copy_from_user (& cmd , buf , sizeof cmd ))
604594 return - EFAULT ;
605595
606- uobj = uobj_get_write (UVERBS_OBJECT_XRCD , cmd .xrcd_handle ,
607- file -> ucontext );
608- if (IS_ERR (uobj ))
609- return PTR_ERR (uobj );
610-
611- ret = uobj_remove_commit (uobj );
612- return ret ?: in_len ;
596+ return uobj_perform_destroy (UVERBS_OBJECT_XRCD , cmd .xrcd_handle , file ,
597+ in_len );
613598}
614599
615600int ib_uverbs_dealloc_xrcd (struct ib_uobject * uobject ,
@@ -829,20 +814,12 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
829814 int out_len )
830815{
831816 struct ib_uverbs_dereg_mr cmd ;
832- struct ib_uobject * uobj ;
833- int ret = - EINVAL ;
834817
835818 if (copy_from_user (& cmd , buf , sizeof cmd ))
836819 return - EFAULT ;
837820
838- uobj = uobj_get_write (UVERBS_OBJECT_MR , cmd .mr_handle ,
839- file -> ucontext );
840- if (IS_ERR (uobj ))
841- return PTR_ERR (uobj );
842-
843- ret = uobj_remove_commit (uobj );
844-
845- return ret ?: in_len ;
821+ return uobj_perform_destroy (UVERBS_OBJECT_MR , cmd .mr_handle , file ,
822+ in_len );
846823}
847824
848825ssize_t ib_uverbs_alloc_mw (struct ib_uverbs_file * file ,
@@ -921,19 +898,12 @@ ssize_t ib_uverbs_dealloc_mw(struct ib_uverbs_file *file,
921898 int out_len )
922899{
923900 struct ib_uverbs_dealloc_mw cmd ;
924- struct ib_uobject * uobj ;
925- int ret = - EINVAL ;
926901
927902 if (copy_from_user (& cmd , buf , sizeof (cmd )))
928903 return - EFAULT ;
929904
930- uobj = uobj_get_write (UVERBS_OBJECT_MW , cmd .mw_handle ,
931- file -> ucontext );
932- if (IS_ERR (uobj ))
933- return PTR_ERR (uobj );
934-
935- ret = uobj_remove_commit (uobj );
936- return ret ?: in_len ;
905+ return uobj_perform_destroy (UVERBS_OBJECT_MW , cmd .mw_handle , file ,
906+ in_len );
937907}
938908
939909ssize_t ib_uverbs_create_comp_channel (struct ib_uverbs_file * file ,
@@ -2641,19 +2611,12 @@ ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
26412611 const char __user * buf , int in_len , int out_len )
26422612{
26432613 struct ib_uverbs_destroy_ah cmd ;
2644- struct ib_uobject * uobj ;
2645- int ret ;
26462614
26472615 if (copy_from_user (& cmd , buf , sizeof cmd ))
26482616 return - EFAULT ;
26492617
2650- uobj = uobj_get_write (UVERBS_OBJECT_AH , cmd .ah_handle ,
2651- file -> ucontext );
2652- if (IS_ERR (uobj ))
2653- return PTR_ERR (uobj );
2654-
2655- ret = uobj_remove_commit (uobj );
2656- return ret ?: in_len ;
2618+ return uobj_perform_destroy (UVERBS_OBJECT_AH , cmd .ah_handle , file ,
2619+ in_len );
26572620}
26582621
26592622ssize_t ib_uverbs_attach_mcast (struct ib_uverbs_file * file ,
@@ -3445,7 +3408,6 @@ int ib_uverbs_ex_destroy_rwq_ind_table(struct ib_uverbs_file *file,
34453408 struct ib_udata * uhw )
34463409{
34473410 struct ib_uverbs_ex_destroy_rwq_ind_table cmd = {};
3448- struct ib_uobject * uobj ;
34493411 int ret ;
34503412 size_t required_cmd_sz ;
34513413
@@ -3466,12 +3428,8 @@ int ib_uverbs_ex_destroy_rwq_ind_table(struct ib_uverbs_file *file,
34663428 if (cmd .comp_mask )
34673429 return - EOPNOTSUPP ;
34683430
3469- uobj = uobj_get_write (UVERBS_OBJECT_RWQ_IND_TBL , cmd .ind_tbl_handle ,
3470- file -> ucontext );
3471- if (IS_ERR (uobj ))
3472- return PTR_ERR (uobj );
3473-
3474- return uobj_remove_commit (uobj );
3431+ return uobj_perform_destroy (UVERBS_OBJECT_RWQ_IND_TBL ,
3432+ cmd .ind_tbl_handle , file , 0 );
34753433}
34763434
34773435int ib_uverbs_ex_create_flow (struct ib_uverbs_file * file ,
@@ -3658,7 +3616,6 @@ int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file,
36583616 struct ib_udata * uhw )
36593617{
36603618 struct ib_uverbs_destroy_flow cmd ;
3661- struct ib_uobject * uobj ;
36623619 int ret ;
36633620
36643621 if (ucore -> inlen < sizeof (cmd ))
@@ -3671,13 +3628,8 @@ int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file,
36713628 if (cmd .comp_mask )
36723629 return - EINVAL ;
36733630
3674- uobj = uobj_get_write (UVERBS_OBJECT_FLOW , cmd .flow_handle ,
3675- file -> ucontext );
3676- if (IS_ERR (uobj ))
3677- return PTR_ERR (uobj );
3678-
3679- ret = uobj_remove_commit (uobj );
3680- return ret ;
3631+ return uobj_perform_destroy (UVERBS_OBJECT_FLOW , cmd .flow_handle , file ,
3632+ 0 );
36813633}
36823634
36833635static int __uverbs_create_xsrq (struct ib_uverbs_file * file ,
0 commit comments