Skip to contentSkip to conversation

AFS: Fix possible null pointer dereference in afs_alloc_server()

PATCH New David Howells 1 participant 1 message Jun 1, 2010 Afs filesystem

lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 AFS: Fix possible null pointer dereference in afs_alloc_server()

From: Denis Kirjanov <[email protected]>

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.

---

 fs/afs/server.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
fs/afs/server.c +3 -2
index f490995..9fdc7fe 100644
@@ -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;
 }