[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d82dae3c12d94db7a2a212a8b8b79e8b@paragon-software.com>
Date: Fri, 4 Sep 2020 12:41:24 +0000
From: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>
To: Al Viro <viro@...iv.linux.org.uk>
CC: "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"pali@...nel.org" <pali@...nel.org>,
"dsterba@...e.cz" <dsterba@...e.cz>,
"aaptel@...e.com" <aaptel@...e.com>,
"willy@...radead.org" <willy@...radead.org>,
"rdunlap@...radead.org" <rdunlap@...radead.org>,
"joe@...ches.com" <joe@...ches.com>,
"mark@...mstone.com" <mark@...mstone.com>
Subject: RE: [PATCH v3 04/10] fs/ntfs3: Add file operations and implementation
From: Al Viro <viro@....linux.org.uk>
Sent: Friday, August 28, 2020 6:46 PM
> On Fri, Aug 28, 2020 at 07:39:32AM -0700, Konstantin Komarov wrote:
>
> > +static struct dentry *__ntfs_lookup(struct inode *dir, struct dentry *dentry,
> > + struct ntfs_fnd *fnd)
> > +{
> > + struct dentry *d;
> > + struct inode *inode;
> > +
> > + inode = dir_search(dir, &dentry->d_name, fnd);
> > +
> > + if (!inode) {
> > + d_add(dentry, NULL);
> > + d = NULL;
> > + goto out;
> > + }
> > +
> > + if (IS_ERR(inode)) {
> > + d = ERR_CAST(inode);
> > + goto out;
> > + }
> > +
> > + d = d_splice_alias(inode, dentry);
> > + if (IS_ERR(d)) {
> > + iput(inode);
> > + goto out;
> > + }
> > +
> > +out:
> > + return d;
> > +}
>
> This is bollocks. First and foremost, d_splice_alias() *does* iput() on
> failure, so you've got double-put there. What's more
> * d_splice_alias(ERR_PTR(err), dentry) return err
> * d_splice_alias(NULL, dentry) is equivalent to d_add(dentry, NULL) and returns NULL
>
> IOW, all that boilerplate could be replaced with one line:
>
> return d_splice_alias(dir_search(dir, &dentry->d_name, fnd), dentry);
Hi Al! Agreed. Will be fixed in v4.
Thanks.
Powered by blists - more mailing lists