Skip to content

Commit a9e01ac

Browse files
dhowellstorvalds
authored andcommitted
afs: Fix overwriting of result of DNS query
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]>
1 parent 937fd40 commit a9e01ac

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

412-
ret = -ENOMEM;
413412
vllist = afs_alloc_vlserver_list(0);
414-
if (!vllist)
413+
if (!vllist) {
414+
if (ret >= 0)
415+
ret = -ENOMEM;
415416
goto out_wake;
417+
}
416418

417419
switch (ret) {
418420
case -ENODATA:

0 commit comments

Comments
 (0)