@@ -233,18 +233,6 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
233
233
return ERR_PTR (- EINVAL );
234
234
}
235
235
236
- /* check the name is unique */
237
- mutex_lock (& heap_list_lock );
238
- list_for_each_entry (h , & heap_list , list ) {
239
- if (!strcmp (h -> name , exp_info -> name )) {
240
- mutex_unlock (& heap_list_lock );
241
- pr_err ("dma_heap: Already registered heap named %s\n" ,
242
- exp_info -> name );
243
- return ERR_PTR (- EINVAL );
244
- }
245
- }
246
- mutex_unlock (& heap_list_lock );
247
-
248
236
heap = kzalloc (sizeof (* heap ), GFP_KERNEL );
249
237
if (!heap )
250
238
return ERR_PTR (- ENOMEM );
@@ -283,13 +271,27 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
283
271
err_ret = ERR_CAST (dev_ret );
284
272
goto err2 ;
285
273
}
286
- /* Add heap to the list */
274
+
287
275
mutex_lock (& heap_list_lock );
276
+ /* check the name is unique */
277
+ list_for_each_entry (h , & heap_list , list ) {
278
+ if (!strcmp (h -> name , exp_info -> name )) {
279
+ mutex_unlock (& heap_list_lock );
280
+ pr_err ("dma_heap: Already registered heap named %s\n" ,
281
+ exp_info -> name );
282
+ err_ret = ERR_PTR (- EINVAL );
283
+ goto err3 ;
284
+ }
285
+ }
286
+
287
+ /* Add heap to the list */
288
288
list_add (& heap -> list , & heap_list );
289
289
mutex_unlock (& heap_list_lock );
290
290
291
291
return heap ;
292
292
293
+ err3 :
294
+ device_destroy (dma_heap_class , heap -> heap_devt );
293
295
err2 :
294
296
cdev_del (& heap -> heap_cdev );
295
297
err1 :
0 commit comments