@@ -1855,22 +1855,18 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
1855
1855
mutex_lock (& xef -> vm .lock );
1856
1856
err = xa_alloc (& xef -> vm .xa , & id , vm , xa_limit_32b , GFP_KERNEL );
1857
1857
mutex_unlock (& xef -> vm .lock );
1858
- if (err ) {
1859
- xe_vm_close_and_put (vm );
1860
- return err ;
1861
- }
1858
+ if (err )
1859
+ goto err_close_and_put ;
1862
1860
1863
1861
if (xe -> info .has_asid ) {
1864
1862
mutex_lock (& xe -> usm .lock );
1865
1863
err = xa_alloc_cyclic (& xe -> usm .asid_to_vm , & asid , vm ,
1866
1864
XA_LIMIT (1 , XE_MAX_ASID - 1 ),
1867
1865
& xe -> usm .next_asid , GFP_KERNEL );
1868
1866
mutex_unlock (& xe -> usm .lock );
1869
- if (err < 0 ) {
1870
- xe_vm_close_and_put (vm );
1871
- return err ;
1872
- }
1873
- err = 0 ;
1867
+ if (err < 0 )
1868
+ goto err_free_id ;
1869
+
1874
1870
vm -> usm .asid = asid ;
1875
1871
}
1876
1872
@@ -1888,6 +1884,15 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
1888
1884
#endif
1889
1885
1890
1886
return 0 ;
1887
+
1888
+ err_free_id :
1889
+ mutex_lock (& xef -> vm .lock );
1890
+ xa_erase (& xef -> vm .xa , id );
1891
+ mutex_unlock (& xef -> vm .lock );
1892
+ err_close_and_put :
1893
+ xe_vm_close_and_put (vm );
1894
+
1895
+ return err ;
1891
1896
}
1892
1897
1893
1898
int xe_vm_destroy_ioctl (struct drm_device * dev , void * data ,
0 commit comments