mtd/fs/jffs2 dir.c,1.72,1.73

David Woodhouse dwmw2 at infradead.org
Mon Aug 26 11:00:54 EDT 2002


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv30318

Modified Files:
	dir.c 
Log Message:
More not oopsing on rename/link/unlink of bad inodes

Index: dir.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/dir.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- dir.c	20 Aug 2002 21:37:28 -0000	1.72
+++ dir.c	26 Aug 2002 15:00:51 -0000	1.73
@@ -233,7 +233,8 @@
 
 	ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, 
 			       dentry->d_name.len, dead_f);
-	dentry->d_inode->i_nlink = dead_f->inocache->nlink;
+	if (dead_f->inocache)
+		dentry->d_inode->i_nlink = dead_f->inocache->nlink;
 	return ret;
 }
 /***********************************************************************/
@@ -247,6 +248,10 @@
 	int ret;
 	uint8_t type;
 
+	/* Don't let people make hard links to bad inodes. */
+	if (!f->inocache)
+		return -EIO;
+
 	if (S_ISDIR(old_dentry->d_inode->i_mode))
 		return -EPERM;
 
@@ -787,7 +792,8 @@
 		struct jffs2_inode_info *f = JFFS2_INODE_INFO(old_dentry->d_inode);
 		down(&f->sem);
 		old_dentry->d_inode->i_nlink++;
-		f->inocache->nlink++;
+		if (f->inocache)
+			f->inocache->nlink++;
 		up(&f->sem);
 
 		printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret);





More information about the linux-mtd-cvs mailing list