Re: [PATCH] fuse: add missing iput() in fuse_lookup() error path

From: Al Viro

Date: Fri Dec 19 2025 - 17:13:44 EST


On Fri, Dec 19, 2025 at 10:10:31PM +0000, Al Viro wrote:
> On Fri, Dec 19, 2025 at 05:43:09PM +0000, Luis Henriques wrote:
> > The inode use count needs to be dropped in the fuse_lookup() error path,
> > when there's an error returned by d_splice_alias().
> >
> > (While there, remove extra white spaces before labels.)
> >
> > Fixes: 5835f3390e35 ("fuse: use d_materialise_unique()")
> > Signed-off-by: Luis Henriques <luis@xxxxxxxxxx>
>
> Have you actually looked at d_splice_alias()?
>
> It does consume inode reference in all cases, success or error. On success
> it gets transferred to dentry; on failure it is dropped. That's quite
> deliberate, since it makes life much simplier for failure handling in the
> callers.
>
> If you can reproduce a leak there, I would like to see a reproducer.
> If not, I would say that your patch introduces a double-iput.
>
> NAK.

PS: out_iput in there is needed only on one failure exit - after we'd
found an inode and before we'd passed it to d_splice_alias().

FWIW, I would rather replace that with
if (inode && get_node_id(inode) == FUSE_ROOT_ID) {
iput(inode);
return ERR_PTR(-EIO);
}
and turned all goto out_err; into direct returns.