Skip to contentSkip to conversation

2.6 patch] fs/gfs2/ops_fstype.c:fill_super_meta(): fix NULL dereference

PATCH Adrian Bunk 2 participants 2 messages Oct 19, 2006 GFS2 file system

lore
Share & tools
lore
#0 lore raw

Don't dereference new->s_root when we do know it's NULL.

Spotted by the Coverity checker.

fs/gfs2/ops_fstype.c renamed from fs/gfs2/ops_fstype.c.old +2 -2
@@ -793,10 +793,10 @@ static int fill_super_meta(struct super_
 	if (!new->s_root) {
 		fs_err(sdp, "can't get root dentry\n");
 		error = -ENOMEM;
 		iput(inode);
-	}
-	new->s_root->d_op = &gfs2_dops;
+	} else
+		new->s_root->d_op = &gfs2_dops;
 
 	return error;
 }
 
#1 lore raw

Hi,

... and this one is pushed to the GFS2 git tree too. Thanks for the
patches,

Steve.

Quoted 22 lines · Adrian Bunk

Don't dereference new->s_root when we do know it's NULL.

Spotted by the Coverity checker.

fs/gfs2/ops_fstype.c renamed from fs/gfs2/ops_fstype.c.old +2 -2
@@ -793,10 +793,10 @@ static int fill_super_meta(struct super_
 	if (!new->s_root) {
 		fs_err(sdp, "can't get root dentry\n");
 		error = -ENOMEM;
 		iput(inode);
-	}
-	new->s_root->d_op = &gfs2_dops;
+	} else
+		new->s_root->d_op = &gfs2_dops;
 
 	return error;
 }