aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:48 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:48 -0500
commit01d0ae8beaee75d954900109619b700fe68707d9 (patch)
tree06180b83f10e0008db9f6bfa6a5fa420bf568ebe /fs/nfs
parentd9f6eb75d4900782a095b98470decfe98971f920 (diff)
NFSv4: Fix an oops in nfs4_fill_super
The mount statistics patches introduced a call to nfs_free_iostats that is not only redundant, but actually causes an oops. Also fix a memory leak due to the lack of a call to nfs_free_iostats on unmount. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/inode.c13
-rw-r--r--fs/nfs/iostat.h3
2 files changed, 8 insertions, 8 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index b9f35ca266c2..17654bffc3c6 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -281,6 +281,10 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
281 281
282 sb->s_magic = NFS_SUPER_MAGIC; 282 sb->s_magic = NFS_SUPER_MAGIC;
283 283
284 server->io_stats = nfs_alloc_iostats();
285 if (server->io_stats == NULL)
286 return -ENOMEM;
287
284 root_inode = nfs_get_root(sb, &server->fh, &fsinfo); 288 root_inode = nfs_get_root(sb, &server->fh, &fsinfo);
285 /* Did getting the root inode fail? */ 289 /* Did getting the root inode fail? */
286 if (IS_ERR(root_inode)) { 290 if (IS_ERR(root_inode)) {
@@ -294,12 +298,6 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
294 } 298 }
295 sb->s_root->d_op = server->rpc_ops->dentry_ops; 299 sb->s_root->d_op = server->rpc_ops->dentry_ops;
296 300
297 server->io_stats = nfs_alloc_iostats();
298 if (!server->io_stats) {
299 no_root_error = -ENOMEM;
300 goto out_no_root;
301 }
302
303 /* mount time stamp, in seconds */ 301 /* mount time stamp, in seconds */
304 server->mount_time = jiffies; 302 server->mount_time = jiffies;
305 303
@@ -1822,6 +1820,7 @@ static void nfs_kill_super(struct super_block *s)
1822 1820
1823 rpciod_down(); /* release rpciod */ 1821 rpciod_down(); /* release rpciod */
1824 1822
1823 nfs_free_iostats(server->io_stats);
1825 kfree(server->hostname); 1824 kfree(server->hostname);
1826 kfree(server); 1825 kfree(server);
1827} 1826}
@@ -2122,7 +2121,6 @@ out_err:
2122out_free: 2121out_free:
2123 kfree(server->mnt_path); 2122 kfree(server->mnt_path);
2124 kfree(server->hostname); 2123 kfree(server->hostname);
2125 nfs_free_iostats(server->io_stats);
2126 kfree(server); 2124 kfree(server);
2127 return s; 2125 return s;
2128} 2126}
@@ -2143,6 +2141,7 @@ static void nfs4_kill_super(struct super_block *sb)
2143 2141
2144 rpciod_down(); 2142 rpciod_down();
2145 2143
2144 nfs_free_iostats(server->io_stats);
2146 kfree(server->hostname); 2145 kfree(server->hostname);
2147 kfree(server); 2146 kfree(server);
2148} 2147}
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h
index 7a7495153317..6350ecbde589 100644
--- a/fs/nfs/iostat.h
+++ b/fs/nfs/iostat.h
@@ -156,7 +156,8 @@ static inline struct nfs_iostats *nfs_alloc_iostats(void)
156 156
157static inline void nfs_free_iostats(struct nfs_iostats *stats) 157static inline void nfs_free_iostats(struct nfs_iostats *stats)
158{ 158{
159 free_percpu(stats); 159 if (stats != NULL)
160 free_percpu(stats);
160} 161}
161 162
162#endif 163#endif