patch-2.0.5 linux/fs/ext2/namei.c

Next file: linux/fs/ncpfs/sock.c
Previous file: linux/drivers/sound/sb_common.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.4/linux/fs/ext2/namei.c linux/fs/ext2/namei.c
@@ -163,10 +163,12 @@
 		return -ENOENT;
 	if (!S_ISDIR(dir->i_mode)) {
 		iput (dir);
-		return -ENOENT;
+		return -ENOTDIR;
 	}
-	if (len > EXT2_NAME_LEN)
+	if (len > EXT2_NAME_LEN) {
+		iput (dir);
 		return -ENAMETOOLONG;
+	}
 	if (dcache_lookup(dir, name, len, &ino)) {
 		if (!ino) {
 			iput(dir);
@@ -407,8 +409,10 @@
 	if (!dir)
 		return -ENOENT;
 
-	if (len > EXT2_NAME_LEN)
+	if (len > EXT2_NAME_LEN) {
+		iput (dir);
 		return -ENAMETOOLONG;
+	}
 	bh = ext2_find_entry (dir, name, len, &de);
 	if (bh) {
 		brelse (bh);
@@ -472,8 +476,10 @@
 
 	if (!dir)
 		return -ENOENT;
-	if (len > EXT2_NAME_LEN)
+	if (len > EXT2_NAME_LEN) {
+		iput (dir);
 		return -ENAMETOOLONG;
+	}
 	bh = ext2_find_entry (dir, name, len, &de);
 	if (bh) {
 		brelse (bh);
@@ -611,8 +617,10 @@
 	if (!dir)
 		return -ENOENT;
 	inode = NULL;
-	if (len > EXT2_NAME_LEN)
+	if (len > EXT2_NAME_LEN) {
+		iput (dir);
 		return -ENAMETOOLONG;
+	}
 	bh = ext2_find_entry (dir, name, len, &de);
 	retval = -ENOENT;
 	if (!bh)
@@ -699,8 +707,10 @@
 		return -ENOENT;
 	retval = -ENOENT;
 	inode = NULL;
-	if (len > EXT2_NAME_LEN)
+	if (len > EXT2_NAME_LEN) {
+		iput (dir);
 		return -ENAMETOOLONG;
+	}
 	bh = ext2_find_entry (dir, name, len, &de);
 	if (!bh)
 		goto end_unlink;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov