[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH 2/5] fsck.gfs2: Fix null pointer deref in check_system_dir()



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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]