Btw, you still have a race in your patch.
You need to test for the negative dentry _after_ getting the parent lock.
So the patch should be something like this (modulo white-space - this got
cut-and-pasted):
--- v2.1.47/linux/fs/namei.c Sun Jul 27 12:11:01 1997
+++ linux/fs/namei.c Mon Aug 4 09:37:25 1997
@@ -831,6 +834,10 @@
dir = lock_parent(dentry);
+ error = -ENOENT;
+ if (!dentry->d_inode)
+ goto exit_lock;
+
error = -EROFS;
if (IS_RDONLY(dir))
goto exit_lock;
but yes, you're correct, this was a real bug.
Linus