Skip to contentSkip to conversation

GFS2: Don't dereference inode in gfs2_inode_lookup until it's valid

PATCH New Bob Peterson 1 participant 1 message Apr 13, 2016 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 GFS2: Don't dereference inode in gfs2_inode_lookup until it's valid

Hi,

Andreas pointed this bug out yesterday:

Function gfs2_inode_lookup was dereferencing the inode, and after, it checks for the value being NULL. We need to check that first.

---

fs/gfs2/inode.c +3 -3
index 57b3dbf..ed3f3615 100644
@@ -113,12 +113,12 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
 	int error;
 
 	inode = iget_locked(sb, (unsigned long)no_addr);
-	ip = GFS2_I(inode);
-	ip->i_no_addr = no_addr;
-
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
+	ip = GFS2_I(inode);
+	ip->i_no_addr = no_addr;
+
 	if (inode->i_state & I_NEW) {
 		struct gfs2_sbd *sdp = GFS2_SB(inode);
 		ip->i_no_formal_ino = no_formal_ino;