Skip to contentSkip to conversation

Fix the handling of dentry on msdos_lookup() (1/4)

PATCH New OGAWA Hirofumi 1 participant 1 message May 25, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix the handling of dentry on msdos_lookup() (1/4)

Hi,

If d_splice_alias() doesn't find the alias dentry, it returns NULL. Then, msdos_lookup() dereference the NULL, and Oops. This patch fixes this.

Side of vfat_lookup() is cleanup only.

Please apply.

Signature · 58 lines
OGAWA Hirofumi <[email protected]>

diff -urN linux-2.5.18/fs/msdos/namei.c fat_dentry-2.5.18/fs/msdos/namei.c
--- linux-2.5.18/fs/msdos/namei.c	Sat May 25 16:52:08 2002
+++ fat_dentry-2.5.18/fs/msdos/namei.c	Sat May 25 17:09:22 2002
@@ -222,22 +222,17 @@
 	if (res)
 		goto out;
 add:
-	if (inode) {
-		dentry = d_splice_alias(inode, dentry);
-		dentry->d_op = &msdos_dentry_operations;
-	} else {
-		d_add(dentry, inode);
-		dentry = NULL;
-	}
 	res = 0;
+	dentry = d_splice_alias(inode, dentry);
+	if (dentry)
+		dentry->d_op = &msdos_dentry_operations;
 out:
 	if (bh)
 		fat_brelse(sb, bh);
 	unlock_kernel();
-	if (res)
-		return ERR_PTR(res);
-	else
+	if (!res)
 		return dentry;
+	return ERR_PTR(res);
 }
 
 /***** Creates a directory entry (name is already formatted). */
diff -urN linux-2.5.18/fs/vfat/namei.c fat_dentry-2.5.18/fs/vfat/namei.c
--- linux-2.5.18/fs/vfat/namei.c	Sat May 25 16:52:14 2002
+++ fat_dentry-2.5.18/fs/vfat/namei.c	Sat May 25 17:09:22 2002
@@ -1021,16 +1021,12 @@
 	unlock_kernel();
 	dentry->d_op = &vfat_dentry_ops[table];
 	dentry->d_time = dentry->d_parent->d_inode->i_version;
-	if (inode) {
-		dentry = d_splice_alias(inode, dentry);
-		if (dentry) {
-			dentry->d_op = &vfat_dentry_ops[table];
-			dentry->d_time = dentry->d_parent->d_inode->i_version;
-		}
-		return dentry;
+	dentry = d_splice_alias(inode, dentry);
+	if (dentry) {
+		dentry->d_op = &vfat_dentry_ops[table];
+		dentry->d_time = dentry->d_parent->d_inode->i_version;
 	}
-	d_add(dentry,inode);
-	return NULL;
+	return dentry;
 }
 
 int vfat_create(struct inode *dir,struct dentry* dentry,int mode)