cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/5] fsck.gfs2: Fix null pointer deref in check_system_dir()
Date: Wed, 18 Jan 2012 16:39:28 +0000	[thread overview]
Message-ID: <1326904771-12416-2-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1326904771-12416-1-git-send-email-anprice@redhat.com>

Spotted by coverity: Dereferencing null variable "sysinode".

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/fsck/pass2.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index c530695..78c9f47 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -623,10 +623,15 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
 
 	log_info( _("Checking system directory inode '%s'\n"), dirname);
 
-	if (sysinode) {
-		iblock = sysinode->i_di.di_num.no_addr;
-		ds.q = block_type(iblock);
+	if (!sysinode) {
+		log_err( _("Failed to check '%s': sysinode is null\n"), dirname);
+		stack;
+		return -1;
 	}
+
+	iblock = sysinode->i_di.di_num.no_addr;
+	ds.q = block_type(iblock);
+
 	pass2_fxns.private = (void *) &ds;
 	if (ds.q == gfs2_bad_block) {
 		/* First check that the directory's metatree is valid */
-- 
1.7.7.5



  reply	other threads:[~2012-01-18 16:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-18 16:39 [Cluster-devel] [PATCH 1/5] fsck.gfs2: Plug memory leak in check_system_dir() Andrew Price
2012-01-18 16:39 ` Andrew Price [this message]
2012-01-18 16:39 ` [Cluster-devel] [PATCH 3/5] fsck.gfs2: Plug a leak in find_block_ref() Andrew Price
2012-01-18 16:39 ` [Cluster-devel] [PATCH 4/5] fsck.gfs2: Remove unused hash.c, hash.h Andrew Price
2012-01-18 16:39 ` [Cluster-devel] [PATCH 5/5] mkfs.gfs2: Improve error messages Andrew Price
2012-01-18 16:48   ` Steven Whitehouse

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=1326904771-12416-2-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.com \
    /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).