Commit e7c58e97 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Fix a page leak in nfs_do_filldir()

nfs_do_filldir() must always free desc->page when it is done, otherwise
we end up leaking the page.

Also remove unused variable 'dentry'.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 5c346854
...@@ -701,11 +701,12 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent, ...@@ -701,11 +701,12 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
int res = 0; int res = 0;
struct nfs_cache_array *array = NULL; struct nfs_cache_array *array = NULL;
unsigned int d_type = DT_UNKNOWN; unsigned int d_type = DT_UNKNOWN;
struct dentry *dentry = NULL;
array = nfs_readdir_get_array(desc->page); array = nfs_readdir_get_array(desc->page);
if (IS_ERR(array)) if (IS_ERR(array)) {
return PTR_ERR(array); res = PTR_ERR(array);
goto out;
}
for (i = desc->cache_entry_index; i < array->size; i++) { for (i = desc->cache_entry_index; i < array->size; i++) {
d_type = DT_UNKNOWN; d_type = DT_UNKNOWN;
...@@ -726,9 +727,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent, ...@@ -726,9 +727,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
desc->eof = 1; desc->eof = 1;
nfs_readdir_release_array(desc->page); nfs_readdir_release_array(desc->page);
out:
cache_page_release(desc); cache_page_release(desc);
if (dentry != NULL)
dput(dentry);
dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n",
(unsigned long long)*desc->dir_cookie, res); (unsigned long long)*desc->dir_cookie, res);
return res; return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment