Skip to content

Commit 19eef1d

Browse files
dhowellstorvalds
authored andcommitted
afs: Fix uninit var in afs_alloc_anon_key()
Fix an uninitialised variable (key) in afs_alloc_anon_key() by setting it to cell->anonymous_key. Without this change, the error check may return a false failure with a bad error number. Most of the time this is unlikely to happen because the first encounter with afs_alloc_anon_key() will usually be from (auto)mount, for which all subsequent operations must wait - apart from other (auto)mounts. Once the call->anonymous_key is allocated, all further calls to afs_request_key() will skip the call to afs_alloc_anon_key() for that cell. Fixes: d27c712 ("afs: Fix delayed allocation of a cell's anonymous key") Reported-by: Paulo Alcantra <pc@manguebit.org> Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Paulo Alcantara <pc@manguebit.org> cc: Marc Dionne <marc.dionne@auristor.com> cc: syzbot+41c68824eefb67cdf00c@syzkaller.appspotmail.com cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e664048 commit 19eef1d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/afs/security.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ static int afs_alloc_anon_key(struct afs_cell *cell)
2626
struct key *key;
2727

2828
mutex_lock(&afs_key_lock);
29-
if (!cell->anonymous_key) {
29+
key = cell->anonymous_key;
30+
if (!key) {
3031
key = rxrpc_get_null_key(cell->key_desc);
3132
if (!IS_ERR(key))
3233
cell->anonymous_key = key;

0 commit comments

Comments
 (0)