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>
This commit is contained in:
@@ -281,6 +281,10 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
|
|||||||
|
|
||||||
sb->s_magic = NFS_SUPER_MAGIC;
|
sb->s_magic = NFS_SUPER_MAGIC;
|
||||||
|
|
||||||
|
server->io_stats = nfs_alloc_iostats();
|
||||||
|
if (server->io_stats == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
root_inode = nfs_get_root(sb, &server->fh, &fsinfo);
|
root_inode = nfs_get_root(sb, &server->fh, &fsinfo);
|
||||||
/* Did getting the root inode fail? */
|
/* Did getting the root inode fail? */
|
||||||
if (IS_ERR(root_inode)) {
|
if (IS_ERR(root_inode)) {
|
||||||
@@ -294,12 +298,6 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
|
|||||||
}
|
}
|
||||||
sb->s_root->d_op = server->rpc_ops->dentry_ops;
|
sb->s_root->d_op = server->rpc_ops->dentry_ops;
|
||||||
|
|
||||||
server->io_stats = nfs_alloc_iostats();
|
|
||||||
if (!server->io_stats) {
|
|
||||||
no_root_error = -ENOMEM;
|
|
||||||
goto out_no_root;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mount time stamp, in seconds */
|
/* mount time stamp, in seconds */
|
||||||
server->mount_time = jiffies;
|
server->mount_time = jiffies;
|
||||||
|
|
||||||
@@ -1822,6 +1820,7 @@ static void nfs_kill_super(struct super_block *s)
|
|||||||
|
|
||||||
rpciod_down(); /* release rpciod */
|
rpciod_down(); /* release rpciod */
|
||||||
|
|
||||||
|
nfs_free_iostats(server->io_stats);
|
||||||
kfree(server->hostname);
|
kfree(server->hostname);
|
||||||
kfree(server);
|
kfree(server);
|
||||||
}
|
}
|
||||||
@@ -2122,7 +2121,6 @@ out_err:
|
|||||||
out_free:
|
out_free:
|
||||||
kfree(server->mnt_path);
|
kfree(server->mnt_path);
|
||||||
kfree(server->hostname);
|
kfree(server->hostname);
|
||||||
nfs_free_iostats(server->io_stats);
|
|
||||||
kfree(server);
|
kfree(server);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -2143,6 +2141,7 @@ static void nfs4_kill_super(struct super_block *sb)
|
|||||||
|
|
||||||
rpciod_down();
|
rpciod_down();
|
||||||
|
|
||||||
|
nfs_free_iostats(server->io_stats);
|
||||||
kfree(server->hostname);
|
kfree(server->hostname);
|
||||||
kfree(server);
|
kfree(server);
|
||||||
}
|
}
|
||||||
|
@@ -156,7 +156,8 @@ static inline struct nfs_iostats *nfs_alloc_iostats(void)
|
|||||||
|
|
||||||
static inline void nfs_free_iostats(struct nfs_iostats *stats)
|
static inline void nfs_free_iostats(struct nfs_iostats *stats)
|
||||||
{
|
{
|
||||||
free_percpu(stats);
|
if (stats != NULL)
|
||||||
|
free_percpu(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user