diff options
author | David Howells <dhowells@redhat.com> | 2019-05-15 14:09:17 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-27 16:50:48 +0300 |
commit | f1e807d39288d39bc157323dc580784d91366f65 (patch) | |
tree | aebf3f0a2be689c8fb29c06f3fa0f879dcebf680 | |
parent | a0a4643f1899b6f9339957d3c7c8e749735be494 (diff) | |
download | linux-f1e807d39288d39bc157323dc580784d91366f65.tar.xz |
afs: Fix key leak in afs_release() and afs_evict_inode()
[ Upstream commit a1b879eefc2b34cd3f17187ef6fc1cf3960e9518 ]
Fix afs_release() to go through the cleanup part of the function if
FMODE_WRITE is set rather than exiting through vfs_fsync() (which skips the
cleanup). The cleanup involves discarding the refs on the key used for
file ops and the writeback key record.
Also fix afs_evict_inode() to clean up any left over wb keys attached to
the inode/vnode when it is removed.
Fixes: 5a8132761609 ("afs: Do better accretion of small writes on newly created content")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | fs/afs/file.c | 7 | ||||
-rw-r--r-- | fs/afs/inode.c | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/fs/afs/file.c b/fs/afs/file.c index 843d3b970b84..0bd78df6a64e 100644 --- a/fs/afs/file.c +++ b/fs/afs/file.c @@ -169,11 +169,12 @@ int afs_release(struct inode *inode, struct file *file) { struct afs_vnode *vnode = AFS_FS_I(inode); struct afs_file *af = file->private_data; + int ret = 0; _enter("{%x:%u},", vnode->fid.vid, vnode->fid.vnode); if ((file->f_mode & FMODE_WRITE)) - return vfs_fsync(file, 0); + ret = vfs_fsync(file, 0); file->private_data = NULL; if (af->wb) @@ -181,8 +182,8 @@ int afs_release(struct inode *inode, struct file *file) key_put(af->key); kfree(af); afs_prune_wb_keys(vnode); - _leave(" = 0"); - return 0; + _leave(" = %d", ret); + return ret; } /* diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 0726e40db0f8..718fab2f151a 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -541,6 +541,7 @@ void afs_evict_inode(struct inode *inode) } #endif + afs_prune_wb_keys(vnode); afs_put_permits(rcu_access_pointer(vnode->permit_cache)); key_put(vnode->lock_key); vnode->lock_key = NULL; |