Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

AFS: Fix possible null pointer dereference in afs_alloc_server()

Fix a possible null pointer dereference in afs_alloc_server(): the server
pointer is NULL if there was an allocation failure, and under such a
condition, we can't dereference it in the _leave() statement.

Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Denis Kirjanov and committed by
Linus Torvalds
037776fc 5c113fbe

+3 -2
+3 -2
fs/afs/server.c
··· 91 91 92 92 memcpy(&server->addr, addr, sizeof(struct in_addr)); 93 93 server->addr.s_addr = addr->s_addr; 94 + _leave(" = %p{%d}", server, atomic_read(&server->usage)); 95 + } else { 96 + _leave(" = NULL [nomem]"); 94 97 } 95 - 96 - _leave(" = %p{%d}", server, atomic_read(&server->usage)); 97 98 return server; 98 99 } 99 100