@@ -79,6 +79,8 @@ static HLIST_HEAD(binder_deferred_list);
7979static DEFINE_MUTEX (binder_deferred_lock );
8080
8181static HLIST_HEAD (binder_devices );
82+ static DEFINE_SPINLOCK (binder_devices_lock );
83+
8284static HLIST_HEAD (binder_procs );
8385static DEFINE_MUTEX (binder_procs_lock );
8486
@@ -6924,7 +6926,16 @@ const struct binder_debugfs_entry binder_debugfs_entries[] = {
69246926
69256927void binder_add_device (struct binder_device * device )
69266928{
6929+ spin_lock (& binder_devices_lock );
69276930 hlist_add_head (& device -> hlist , & binder_devices );
6931+ spin_unlock (& binder_devices_lock );
6932+ }
6933+
6934+ void binder_remove_device (struct binder_device * device )
6935+ {
6936+ spin_lock (& binder_devices_lock );
6937+ hlist_del_init (& device -> hlist );
6938+ spin_unlock (& binder_devices_lock );
69286939}
69296940
69306941static int __init init_binder_device (const char * name )
@@ -6951,7 +6962,7 @@ static int __init init_binder_device(const char *name)
69516962 return ret ;
69526963 }
69536964
6954- hlist_add_head ( & binder_device -> hlist , & binder_devices );
6965+ binder_add_device ( binder_device );
69556966
69566967 return ret ;
69576968}
@@ -7013,7 +7024,7 @@ static int __init binder_init(void)
70137024err_init_binder_device_failed :
70147025 hlist_for_each_entry_safe (device , tmp , & binder_devices , hlist ) {
70157026 misc_deregister (& device -> miscdev );
7016- hlist_del ( & device -> hlist );
7027+ binder_remove_device ( device );
70177028 kfree (device );
70187029 }
70197030
0 commit comments