netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huzaifa Sidhpurwala <huzaifas@redhat.com>
To: netdev@vger.kernel.org
Cc: kaber@trash.net, yoshfuji@linux-ipv6.org, jmorris@namei.org,
	pekkas@netcore.fi, kuznet@ms2.inr.ac.ru, davem@davemloft.net,
	Huzaifa Sidhpurwala <huzaifas@redhat.com>
Subject: [PATCH] Check the value of doi before referencing it
Date: Wed, 18 May 2011 09:59:40 +0530	[thread overview]
Message-ID: <1305692980-4730-1-git-send-email-huzaifas@redhat.com> (raw)

Value of doi is not checked before referencing it.
Though this does not cause any null pointer dereference since
all the callers of cipso_v4_doi_add check the value of doi
before calling the function, but it would be a good programming
practice to do so anyways :)

Signed-off-by: Huzaifa Sidhpurwala <huzaifas@redhat.com>
---
 net/ipv4/cipso_ipv4.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index a0af7ea..7adc4ea 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -473,10 +473,13 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def,
 	u32 doi_type;
 	struct audit_buffer *audit_buf;
 
-	doi = doi_def->doi;
-	doi_type = doi_def->type;
+	if (doi_def) {
+		doi = doi_def->doi;
+		doi_type = doi_def->type;
+	} else
+	goto doi_add_return;
 
-	if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
+	if (doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
 		goto doi_add_return;
 	for (iter = 0; iter < CIPSO_V4_TAG_MAXCNT; iter++) {
 		switch (doi_def->tags[iter]) {
-- 
1.7.1


             reply	other threads:[~2011-05-18  4:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18  4:29 Huzaifa Sidhpurwala [this message]
2011-05-18  5:04 ` [PATCH] Check the value of doi before referencing it David Miller
2011-05-18 22:32   ` Paul Moore

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=1305692980-4730-1-git-send-email-huzaifas@redhat.com \
    --to=huzaifas@redhat.com \
    --cc=davem@davemloft.net \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@vger.kernel.org \
    --cc=pekkas@netcore.fi \
    --cc=yoshfuji@linux-ipv6.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).