AFS: Fix possible null pointer dereference in afs_alloc_server()
authorDenis Kirjanov <dkirjanov@hera.kernel.org>
Tue, 1 Jun 2010 16:15:39 +0000 (17:15 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 1 Jun 2010 16:26:36 +0000 (09:26 -0700)
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>
fs/afs/server.c

index f4909951667554b6e4263ebebedc6d2513599d48..9fdc7fe3a7bc127da02963e76c3628221c334ed0 100644 (file)
@@ -91,9 +91,10 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell,
 
                memcpy(&server->addr, addr, sizeof(struct in_addr));
                server->addr.s_addr = addr->s_addr;
+               _leave(" = %p{%d}", server, atomic_read(&server->usage));
+       } else {
+               _leave(" = NULL [nomem]");
        }
-
-       _leave(" = %p{%d}", server, atomic_read(&server->usage));
        return server;
 }