[PATCH] JFS: jfs_lookup should check for bad inode returned from iget (2 of 3)

Dave Kleikamp <[email protected]> Tue, 22 Apr 2003 09:42:45 -0500
Newsgroups gmane.comp.file-systems.jfs.patches
Message-ID <[email protected]>
# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1101.1.1 -> 1.1101.1.2
#	      fs/jfs/namei.c	1.15    -> 1.16   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/04/17	[email protected]	1.1101.1.2
# JFS: jfs_lookup should check for bad inode returned from iget
# 
# A bad inode from iget indicates that jfs_read_inode failed.  jfs_lookup
# needs to check for the bad inode, or we run into trouble later if we
# expect the inode to be properly initialized.
# --------------------------------------------
#
diff -Nru a/fs/jfs/namei.c b/fs/jfs/namei.c
--- a/fs/jfs/namei.c	Tue Apr 22 09:18:56 2003
+++ b/fs/jfs/namei.c	Tue Apr 22 09:18:56 2003
@@ -1394,6 +1394,12 @@
 		jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum);
 		return ERR_PTR(-EACCES);
 	}
+	if (is_bad_inode(ip)) {
+		jfs_err("jfs_lookup: iget returned bad inode, inum = %d",
+			(uint) inum);
+		iput(ip);
+		return ERR_PTR(-EACCES);
+	}
 
 	d_add(dentry, ip);