Skip to content

Commit 47ae524

Browse files
dhowellsgregkh
authored andcommitted
afs: Fix overwriting of result of DNS query
[ Upstream commit a9e01ac ] 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: d5c32c8 ("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/ [1] Link: https://lore.kernel.org/r/1700862.1703168632@warthog.procyon.org.uk/ # v1 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c04b7b2 commit 47ae524

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/afs/cell.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,12 @@ static int afs_update_cell(struct afs_cell *cell)
404404
if (ret == -ENOMEM)
405405
goto out_wake;
406406

407-
ret = -ENOMEM;
408407
vllist = afs_alloc_vlserver_list(0);
409-
if (!vllist)
408+
if (!vllist) {
409+
if (ret >= 0)
410+
ret = -ENOMEM;
410411
goto out_wake;
412+
}
411413

412414
switch (ret) {
413415
case -ENODATA:

0 commit comments

Comments
 (0)