All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kirjanov <dkirjanov@hera.kernel.org>
To: dhowells@redhat.com
Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] afs: fix possible null pointer dereference in afs_alloc_server
Date: Sun, 30 May 2010 07:59:27 +0000	[thread overview]
Message-ID: <20100530075927.GA4912@hera.kernel.org> (raw)

Fix possible null pointer dereference since kzalloc can return null

Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org>
---
fs/afs/server.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/afs/server.c b/fs/afs/server.c
index f490995..32e2a91 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -93,7 +93,10 @@ static struct afs_server *afs_alloc_server(struct afs_cell *cell,
 		server->addr.s_addr = addr->s_addr;
 	}
 
-	_leave(" = %p{%d}", server, atomic_read(&server->usage));
+	if (likely(server))
+		_leave(" = %p{%d}", server, atomic_read(&server->usage));
+	else
+		_leave(" = -ENOMEM");
 	return server;
 }
 

             reply	other threads:[~2010-05-30  7:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-30  7:59 Denis Kirjanov [this message]
2010-06-01 15:47 ` [PATCH] afs: fix possible null pointer dereference in afs_alloc_server David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100530075927.GA4912@hera.kernel.org \
    --to=dkirjanov@hera.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.