public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Brauner <christian@brauner.io>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Hridya Valsaraju" <hridya@google.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Martijn Coenen" <maco@android.com>,
	"Joel Fernandes" <joel@joelfernandes.org>,
	"Christian Brauner" <christian@brauner.io>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	"Christian Brauner" <christian.brauner@ubuntu.com>,
	kernel-team@android.com
Subject: Re: [PATCH v2 1/2] binder: Add default binder devices through binderfs when configured
Date: Wed, 7 Aug 2019 19:50:06 +0200	[thread overview]
Message-ID: <20190807174937.53qo7uninqi3c6xq@brauner.io> (raw)
In-Reply-To: <20190807110204.GL1974@kadam>

On Wed, Aug 07, 2019 at 02:02:05PM +0300, Dan Carpenter wrote:
> On Tue, Aug 06, 2019 at 11:40:05AM -0700, Hridya Valsaraju wrote:
> > @@ -467,6 +466,9 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> >  	int ret;
> >  	struct binderfs_info *info;
> >  	struct inode *inode = NULL;
> > +	struct binderfs_device device_info = { 0 };
> > +	const char *name;
> > +	size_t len;
> >  
> >  	sb->s_blocksize = PAGE_SIZE;
> >  	sb->s_blocksize_bits = PAGE_SHIFT;
> > @@ -521,7 +523,24 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> >  	if (!sb->s_root)
> >  		return -ENOMEM;
> >  
> > -	return binderfs_binder_ctl_create(sb);
> > +	ret = binderfs_binder_ctl_create(sb);
> > +	if (ret)
> > +		return ret;
> > +
> > +	name = binder_devices_param;
> > +	for (len = strcspn(name, ","); len > 0; len = strcspn(name, ",")) {
> > +		strscpy(device_info.name, name, len + 1);
> > +		ret = binderfs_binder_device_create(inode, NULL, &device_info);
> > +		if (ret)
> > +			return ret;
> 
> We should probably clean up before returning...  The error handling code
> would probably be tricky to write though and it's not super common.

struct dentry *mount_nodev(struct file_system_type *fs_type,
	int flags, void *data,
	int (*fill_super)(struct super_block *, void *, int))
{
	<snip>

	error = fill_super(s, data, flags & SB_SILENT ? 1 : 0);
	if (error) {
		deactivate_locked_super(s);
		return ERR_PTR(error);
	}

	<snip>
}

	deactivate_locked_super()
will call
	fs->kill_sb(s)
which calls
	binderfs_kill_super()
which calls
	kill_litter_super()
the latter will destory any remaining dentries and then calls
	generic_shutdown_super()
which calls
	evict_inodes()
which calls
	evict(inode)
which calls the binderfs specific
	binderfs_evict_inode()
and get rid of the rest.

So manually cleaning up is not needed, imho.

Christian

  parent reply	other threads:[~2019-08-07 17:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 18:40 [PATCH v2 0/2] Add default binderfs devices Hridya Valsaraju
2019-08-06 18:40 ` [PATCH v2 1/2] binder: Add default binder devices through binderfs when configured Hridya Valsaraju
2019-08-07 11:02   ` Dan Carpenter
2019-08-07 16:51     ` Hridya Valsaraju
2019-08-09  9:25       ` Dan Carpenter
2019-08-07 17:50     ` Christian Brauner [this message]
2019-08-06 18:40 ` [PATCH v2 2/2] binder: Validate the default binderfs device names Hridya Valsaraju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190807174937.53qo7uninqi3c6xq@brauner.io \
    --to=christian@brauner.io \
    --cc=arve@android.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hridya@google.com \
    --cc=joel@joelfernandes.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@android.com \
    --cc=tkjos@android.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox