Skip to content

Commit 12d909c

Browse files
eggonleagregkh
authored andcommitted
binderfs: add new binder devices to binder_devices
When binderfs is not enabled, the binder driver parses the kernel config to create all binder devices. All of the new binder devices are stored in the list binder_devices. When binderfs is enabled, the binder driver creates new binder devices dynamically when userspace applications call BINDER_CTL_ADD ioctl. But the devices created in this way are not stored in the same list. This patch fixes that. Signed-off-by: Li Li <[email protected]> Acked-by: Carlos Llamas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b3b9b3c commit 12d909c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

drivers/android/binder.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6928,6 +6928,11 @@ const struct binder_debugfs_entry binder_debugfs_entries[] = {
69286928
{} /* terminator */
69296929
};
69306930

6931+
void binder_add_device(struct binder_device *device)
6932+
{
6933+
hlist_add_head(&device->hlist, &binder_devices);
6934+
}
6935+
69316936
static int __init init_binder_device(const char *name)
69326937
{
69336938
int ret;

drivers/android/binder_internal.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ struct binder_context {
2525

2626
/**
2727
* struct binder_device - information about a binder device node
28-
* @hlist: list of binder devices (only used for devices requested via
29-
* CONFIG_ANDROID_BINDER_DEVICES)
28+
* @hlist: list of binder devices
3029
* @miscdev: information about a binder character device node
3130
* @context: binder context information
3231
* @binderfs_inode: This is the inode of the root dentry of the super block
@@ -582,4 +581,12 @@ struct binder_object {
582581
};
583582
};
584583

584+
/**
585+
* Add a binder device to binder_devices
586+
* @device: the new binder device to add to the global list
587+
*
588+
* Not reentrant as the list is not protected by any locks
589+
*/
590+
void binder_add_device(struct binder_device *device);
591+
585592
#endif /* _LINUX_BINDER_INTERNAL_H */

drivers/android/binderfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ static int binderfs_binder_device_create(struct inode *ref_inode,
207207
fsnotify_create(root->d_inode, dentry);
208208
inode_unlock(d_inode(root));
209209

210+
binder_add_device(device);
211+
210212
return 0;
211213

212214
err:

0 commit comments

Comments
 (0)