]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
afs: Fix overwriting of result of DNS query
authorDavid Howells <dhowells@redhat.com>
Thu, 21 Dec 2023 15:09:31 +0000 (15:09 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jan 2024 14:12:25 +0000 (15:12 +0100)
commit3dce7a52b2fa7035840e82f684c0ee323b64c944
tree0601c573e1e7115c1df4844a25ffb53c8a5bb7ab
parent97be1e865e70e5a0ad0a5b5f5dca5031ca0b53ac
afs: Fix overwriting of result of DNS query

[ Upstream commit a9e01ac8c5ff32669119c40dfdc9e80eb0b7d7aa ]

In afs_update_cell(), ret is the result of the DNS lookup and the errors
are to be handled by a switch - however, the value gets clobbered in
between by setting it to -ENOMEM in case afs_alloc_vlserver_list()
fails.

Fix this by moving the setting of -ENOMEM into the error handling for
OOM failure.  Further, only do it if we don't have an alternative error
to return.

Found by Linux Verification Center (linuxtesting.org) with SVACE.  Based
on a patch from Anastasia Belova [1].

Fixes: d5c32c89b208 ("afs: Fix cell DNS lookup")
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
cc: Anastasia Belova <abelova@astralinux.ru>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: lvc-project@linuxtesting.org
Link: https://lore.kernel.org/r/20231221085849.1463-1-abelova@astralinux.ru/
Link: https://lore.kernel.org/r/1700862.1703168632@warthog.procyon.org.uk/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/afs/cell.c