Skip to content

Commit 59d4907

Browse files
committed
afs: Fix key refcounting in file locking code
Fix the refcounting of the authentication keys in the file locking code. The vnode->lock_key member points to a key on which it expects to be holding a ref, but it isn't always given an extra ref, however. Fixes: 0fafdc9 ("afs: Fix file locking") Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 4882a27 commit 59d4907

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

fs/afs/flock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void afs_lock_work(struct work_struct *work)
208208
/* The new front of the queue now owns the state variables. */
209209
next = list_entry(vnode->pending_locks.next,
210210
struct file_lock, fl_u.afs.link);
211-
vnode->lock_key = afs_file_key(next->fl_file);
211+
vnode->lock_key = key_get(afs_file_key(next->fl_file));
212212
vnode->lock_type = (next->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE;
213213
vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB;
214214
goto again;
@@ -413,7 +413,7 @@ static void afs_dequeue_lock(struct afs_vnode *vnode, struct file_lock *fl)
413413
/* The new front of the queue now owns the state variables. */
414414
next = list_entry(vnode->pending_locks.next,
415415
struct file_lock, fl_u.afs.link);
416-
vnode->lock_key = afs_file_key(next->fl_file);
416+
vnode->lock_key = key_get(afs_file_key(next->fl_file));
417417
vnode->lock_type = (next->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE;
418418
vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB;
419419
afs_lock_may_be_available(vnode);

fs/afs/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ void afs_evict_inode(struct inode *inode)
545545
#endif
546546

547547
afs_put_permits(rcu_access_pointer(vnode->permit_cache));
548+
key_put(vnode->lock_key);
549+
vnode->lock_key = NULL;
548550
_leave("");
549551
}
550552

0 commit comments

Comments
 (0)