gfs2-utils: master - fsck.gfs2: Fix null pointer deref in check_system_dir()

Andrew Price andyp at fedoraproject.org
Wed Jan 18 16:54:23 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d0a0e58a4de53a0c582acc1d6a9333e7502f0168
Commit:        d0a0e58a4de53a0c582acc1d6a9333e7502f0168
Parent:        5eb51a7d94b89a53427fff36ba041caf92d35508
Author:        Andrew Price <anprice at redhat.com>
AuthorDate:    Fri Jan 13 11:41:02 2012 +0000
Committer:     Andrew Price <anprice at redhat.com>
CommitterDate: Fri Jan 13 11:41:02 2012 +0000

fsck.gfs2: Fix null pointer deref in check_system_dir()

Spotted by coverity: Dereferencing null variable "sysinode".

Signed-off-by: Andrew Price <anprice at 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 */


More information about the cluster-commits mailing list