Skip to content

Commit 3dce7a5

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 <[email protected]> Reviewed-by: Jeffrey Altman <[email protected]> cc: Anastasia Belova <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ [1] Link: https://lore.kernel.org/r/[email protected]/ # v1 Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 97be1e8 commit 3dce7a5

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
@@ -407,10 +407,12 @@ static int afs_update_cell(struct afs_cell *cell)
407407
if (ret == -ENOMEM)
408408
goto out_wake;
409409

410-
ret = -ENOMEM;
411410
vllist = afs_alloc_vlserver_list(0);
412-
if (!vllist)
411+
if (!vllist) {
412+
if (ret >= 0)
413+
ret = -ENOMEM;
413414
goto out_wake;
415+
}
414416

415417
switch (ret) {
416418
case -ENODATA:

0 commit comments

Comments
 (0)