Skip to content

Commit 36975fc

Browse files
braunergregkh
authored andcommitted
binderfs: rework binderfs_fill_super()
Al pointed out that on binderfs_fill_super() error deactivate_locked_super() will call binderfs_kill_super() so all of the freeing and putting we currently do in binderfs_fill_super() is unnecessary and buggy. Let's simply return errors and let binderfs_fill_super() take care of cleaning up on error. Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christian Brauner <christian@brauner.io> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e98e6fa commit 36975fc

1 file changed

Lines changed: 11 additions & 30 deletions

File tree

‎drivers/android/binderfs.c‎

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,9 @@ static const struct inode_operations binderfs_dir_inode_operations = {
461461

462462
static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
463463
{
464+
int ret;
464465
struct binderfs_info *info;
465-
int ret = -ENOMEM;
466466
struct inode *inode = NULL;
467-
struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
468-
469-
get_ipc_ns(ipc_ns);
470467

471468
sb->s_blocksize = PAGE_SIZE;
472469
sb->s_blocksize_bits = PAGE_SHIFT;
@@ -488,28 +485,27 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
488485
sb->s_op = &binderfs_super_ops;
489486
sb->s_time_gran = 1;
490487

491-
info = kzalloc(sizeof(struct binderfs_info), GFP_KERNEL);
492-
if (!info)
493-
goto err_without_dentry;
488+
sb->s_fs_info = kzalloc(sizeof(struct binderfs_info), GFP_KERNEL);
489+
if (!sb->s_fs_info)
490+
return -ENOMEM;
491+
info = sb->s_fs_info;
492+
493+
info->ipc_ns = get_ipc_ns(current->nsproxy->ipc_ns);
494494

495495
ret = binderfs_parse_mount_opts(data, &info->mount_opts);
496496
if (ret)
497-
goto err_without_dentry;
497+
return ret;
498498

499-
info->ipc_ns = ipc_ns;
500499
info->root_gid = make_kgid(sb->s_user_ns, 0);
501500
if (!gid_valid(info->root_gid))
502501
info->root_gid = GLOBAL_ROOT_GID;
503502
info->root_uid = make_kuid(sb->s_user_ns, 0);
504503
if (!uid_valid(info->root_uid))
505504
info->root_uid = GLOBAL_ROOT_UID;
506505

507-
sb->s_fs_info = info;
508-
509-
ret = -ENOMEM;
510506
inode = new_inode(sb);
511507
if (!inode)
512-
goto err_without_dentry;
508+
return -ENOMEM;
513509

514510
inode->i_ino = FIRST_INODE;
515511
inode->i_fop = &simple_dir_operations;
@@ -520,24 +516,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
520516

521517
sb->s_root = d_make_root(inode);
522518
if (!sb->s_root)
523-
goto err_without_dentry;
524-
525-
ret = binderfs_binder_ctl_create(sb);
526-
if (ret)
527-
goto err_with_dentry;
528-
529-
return 0;
530-
531-
err_with_dentry:
532-
dput(sb->s_root);
533-
sb->s_root = NULL;
534-
535-
err_without_dentry:
536-
put_ipc_ns(ipc_ns);
537-
iput(inode);
538-
kfree(info);
519+
return -ENOMEM;
539520

540-
return ret;
521+
return binderfs_binder_ctl_create(sb);
541522
}
542523

543524
static struct dentry *binderfs_mount(struct file_system_type *fs_type,

0 commit comments

Comments
 (0)