lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit abf0f6a2 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Greg Kroah-Hartman

GFS2: fix dentry leaks

commit 5ca1db41 upstream.

We need to dput() the result of d_splice_alias(), unless it is passed to
finish_no_open().

Edited by Steven Whitehouse in order to make it apply to the current
GFS2 git tree, and taking account of a prerequisite patch which hasn't
been applied.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ae2d3f3d
...@@ -585,12 +585,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, ...@@ -585,12 +585,14 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
d = d_splice_alias(inode, dentry); d = d_splice_alias(inode, dentry);
error = 0; error = 0;
if (file) { if (file) {
if (d == NULL) if (S_ISREG(inode->i_mode)) {
d = dentry; WARN_ON(d != NULL);
if (S_ISREG(inode->i_mode)) error = finish_open(file, dentry, gfs2_open_common, opened);
error = finish_open(file, d, gfs2_open_common, opened); } else {
else
error = finish_no_open(file, d); error = finish_no_open(file, d);
}
} else {
dput(d);
} }
gfs2_glock_dq_uninit(ghs); gfs2_glock_dq_uninit(ghs);
return error; return error;
...@@ -779,8 +781,10 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry, ...@@ -779,8 +781,10 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
error = finish_open(file, dentry, gfs2_open_common, opened); error = finish_open(file, dentry, gfs2_open_common, opened);
gfs2_glock_dq_uninit(&gh); gfs2_glock_dq_uninit(&gh);
if (error) if (error) {
dput(d);
return ERR_PTR(error); return ERR_PTR(error);
}
return d; return d;
} }
...@@ -1161,14 +1165,16 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -1161,14 +1165,16 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
d = __gfs2_lookup(dir, dentry, file, opened); d = __gfs2_lookup(dir, dentry, file, opened);
if (IS_ERR(d)) if (IS_ERR(d))
return PTR_ERR(d); return PTR_ERR(d);
if (d == NULL) if (d != NULL)
d = dentry; dentry = d;
if (d->d_inode) { if (dentry->d_inode) {
if (!(*opened & FILE_OPENED)) if (!(*opened & FILE_OPENED))
return finish_no_open(file, d); return finish_no_open(file, dentry);
dput(d);
return 0; return 0;
} }
BUG_ON(d != NULL);
if (!(flags & O_CREAT)) if (!(flags & O_CREAT))
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment