@@ -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
@@ -6929,7 +6931,16 @@ const struct binder_debugfs_entry binder_debugfs_entries[] = {
69296931
69306932void  binder_add_device (struct  binder_device  * device )
69316933{
6934+ 	spin_lock (& binder_devices_lock );
69326935	hlist_add_head (& device -> hlist , & binder_devices );
6936+ 	spin_unlock (& binder_devices_lock );
6937+ }
6938+ 
6939+ void  binder_remove_device (struct  binder_device  * device )
6940+ {
6941+ 	spin_lock (& binder_devices_lock );
6942+ 	hlist_del_init (& device -> hlist );
6943+ 	spin_unlock (& binder_devices_lock );
69336944}
69346945
69356946static  int  __init  init_binder_device (const  char  * name )
@@ -6956,7 +6967,7 @@ static int __init init_binder_device(const char *name)
69566967		return  ret ;
69576968	}
69586969
6959- 	hlist_add_head ( & binder_device -> hlist ,  & binder_devices );
6970+ 	binder_add_device ( binder_device );
69606971
69616972	return  ret ;
69626973}
@@ -7018,7 +7029,7 @@ static int __init binder_init(void)
70187029err_init_binder_device_failed :
70197030	hlist_for_each_entry_safe (device , tmp , & binder_devices , hlist ) {
70207031		misc_deregister (& device -> miscdev );
7021- 		hlist_del ( & device -> hlist );
7032+ 		binder_remove_device ( device );
70227033		kfree (device );
70237034	}
70247035
0 commit comments