@@ -2940,6 +2940,7 @@ static int iommu_setup_default_domain(struct iommu_group *group,
2940
2940
static ssize_t iommu_group_store_type (struct iommu_group * group ,
2941
2941
const char * buf , size_t count )
2942
2942
{
2943
+ struct group_device * gdev ;
2943
2944
int ret , req_type ;
2944
2945
2945
2946
if (!capable (CAP_SYS_ADMIN ) || !capable (CAP_SYS_RAWIO ))
@@ -2964,20 +2965,23 @@ static ssize_t iommu_group_store_type(struct iommu_group *group,
2964
2965
if (req_type == IOMMU_DOMAIN_DMA_FQ &&
2965
2966
group -> default_domain -> type == IOMMU_DOMAIN_DMA ) {
2966
2967
ret = iommu_dma_init_fq (group -> default_domain );
2967
- if (!ret )
2968
- group -> default_domain -> type = IOMMU_DOMAIN_DMA_FQ ;
2969
- mutex_unlock (& group -> mutex );
2968
+ if (ret )
2969
+ goto out_unlock ;
2970
2970
2971
- return ret ?: count ;
2971
+ group -> default_domain -> type = IOMMU_DOMAIN_DMA_FQ ;
2972
+ ret = count ;
2973
+ goto out_unlock ;
2972
2974
}
2973
2975
2974
2976
/* Otherwise, ensure that device exists and no driver is bound. */
2975
2977
if (list_empty (& group -> devices ) || group -> owner_cnt ) {
2976
- mutex_unlock ( & group -> mutex ) ;
2977
- return - EPERM ;
2978
+ ret = - EPERM ;
2979
+ goto out_unlock ;
2978
2980
}
2979
2981
2980
2982
ret = iommu_setup_default_domain (group , req_type );
2983
+ if (ret )
2984
+ goto out_unlock ;
2981
2985
2982
2986
/*
2983
2987
* Release the mutex here because ops->probe_finalize() call-back of
@@ -2988,13 +2992,12 @@ static ssize_t iommu_group_store_type(struct iommu_group *group,
2988
2992
mutex_unlock (& group -> mutex );
2989
2993
2990
2994
/* Make sure dma_ops is appropriatley set */
2991
- if (!ret ) {
2992
- struct group_device * gdev ;
2993
-
2994
- for_each_group_device (group , gdev )
2995
- iommu_group_do_probe_finalize (gdev -> dev );
2996
- }
2995
+ for_each_group_device (group , gdev )
2996
+ iommu_group_do_probe_finalize (gdev -> dev );
2997
+ return count ;
2997
2998
2999
+ out_unlock :
3000
+ mutex_unlock (& group -> mutex );
2998
3001
return ret ?: count ;
2999
3002
}
3000
3003
0 commit comments