@@ -756,22 +756,21 @@ struct dma_chan *dma_request_chan(struct device *dev, const char *name)
756
756
}
757
757
mutex_unlock (& dma_list_mutex );
758
758
759
- if (!IS_ERR_OR_NULL (chan ))
760
- goto found ;
761
-
762
- return ERR_PTR (- EPROBE_DEFER );
759
+ if (IS_ERR_OR_NULL (chan ))
760
+ return chan ? chan : ERR_PTR (- EPROBE_DEFER );
763
761
764
762
found :
765
- chan -> slave = dev ;
766
763
chan -> name = kasprintf (GFP_KERNEL , "dma:%s" , name );
767
764
if (!chan -> name )
768
- return ERR_PTR (- ENOMEM );
765
+ return chan ;
766
+ chan -> slave = dev ;
769
767
770
768
if (sysfs_create_link (& chan -> dev -> device .kobj , & dev -> kobj ,
771
769
DMA_SLAVE_NAME ))
772
- dev_err (dev , "Cannot create DMA %s symlink\n" , DMA_SLAVE_NAME );
770
+ dev_warn (dev , "Cannot create DMA %s symlink\n" , DMA_SLAVE_NAME );
773
771
if (sysfs_create_link (& dev -> kobj , & chan -> dev -> device .kobj , chan -> name ))
774
- dev_err (dev , "Cannot create DMA %s symlink\n" , chan -> name );
772
+ dev_warn (dev , "Cannot create DMA %s symlink\n" , chan -> name );
773
+
775
774
return chan ;
776
775
}
777
776
EXPORT_SYMBOL_GPL (dma_request_chan );
@@ -830,13 +829,14 @@ void dma_release_channel(struct dma_chan *chan)
830
829
/* drop PRIVATE cap enabled by __dma_request_channel() */
831
830
if (-- chan -> device -> privatecnt == 0 )
832
831
dma_cap_clear (DMA_PRIVATE , chan -> device -> cap_mask );
832
+
833
833
if (chan -> slave ) {
834
+ sysfs_remove_link (& chan -> dev -> device .kobj , DMA_SLAVE_NAME );
834
835
sysfs_remove_link (& chan -> slave -> kobj , chan -> name );
835
836
kfree (chan -> name );
836
837
chan -> name = NULL ;
837
838
chan -> slave = NULL ;
838
839
}
839
- sysfs_remove_link (& chan -> dev -> device .kobj , DMA_SLAVE_NAME );
840
840
mutex_unlock (& dma_list_mutex );
841
841
}
842
842
EXPORT_SYMBOL_GPL (dma_release_channel );
@@ -962,6 +962,9 @@ static int __dma_async_device_channel_register(struct dma_device *device,
962
962
963
963
tchan = list_first_entry_or_null (& device -> channels ,
964
964
struct dma_chan , device_node );
965
+ if (!tchan )
966
+ return - ENODEV ;
967
+
965
968
if (tchan -> dev ) {
966
969
idr_ref = tchan -> dev -> idr_ref ;
967
970
} else {
0 commit comments