From: <viro@parcelfarce.linux.theplanet.co.uk>

The fix we need is the following - we want to make sure that we don't leave
non-NULL ->s_root and in case if we'd failed after allocating root dentry
do dput() instead of iput().



---

 fs/nfs/inode.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff -puN fs/nfs/inode.c~nfs-mount-error-recovery fs/nfs/inode.c
--- 25/fs/nfs/inode.c~nfs-mount-error-recovery	2004-02-19 23:26:04.000000000 -0800
+++ 25-akpm/fs/nfs/inode.c	2004-02-19 23:26:04.000000000 -0800
@@ -301,18 +301,25 @@ nfs_sb_init(struct super_block *sb, rpc_
 	sb->s_magic      = NFS_SUPER_MAGIC;
 
 	/* Did getting the root inode fail? */
-	if (nfs_get_root(&root_inode, authflavor, sb, &server->fh) < 0)
-		goto out_no_root;
+	if (nfs_get_root(&root_inode, authflavor, sb, &server->fh) < 0) {
+		printk("nfs_read_super: get root inode failed\n");
+		goto out;
+	}
 	sb->s_root = d_alloc_root(root_inode);
-	if (!sb->s_root)
-		goto out_no_root;
+	if (!sb->s_root) {
+		printk("nfs_read_super: out of memory\n");
+		iput(root_inode);
+		goto out;
+	}
 
 	sb->s_root->d_op = server->rpc_ops->dentry_ops;
 
 	/* Get some general file system info */
         if (server->rpc_ops->fsinfo(server, &server->fh, &fsinfo) < 0) {
 		printk(KERN_NOTICE "NFS: cannot retrieve file system info.\n");
-		goto out_no_root;
+		dput(sb->s_root);
+		sb->s_root = NULL;
+		goto out;
         }
 	if (server->namelen == 0 &&
 	    server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0)
@@ -368,14 +375,10 @@ nfs_sb_init(struct super_block *sb, rpc_
 	/* We're airborne Set socket buffersize */
 	rpc_setbufsize(server->client, server->wsize + 100, server->rsize + 100);
 	return 0;
+
 	/* Yargs. It didn't work out. */
-out_free_all:
-	if (root_inode)
-		iput(root_inode);
+out:
 	return -EINVAL;
-out_no_root:
-	printk("nfs_read_super: get root inode failed\n");
-	goto out_free_all;
 }
 
 /*

_