mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-24 05:04:00 +08:00
nfsd: Fix a memory leak in nfsd4_list_rec_dir()
If lookup_one_len() failed, nfsd should free those memory allocated for fname. Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
1ca4b88e7d
commit
4691b271ac
@ -272,6 +272,7 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
|
|||||||
.ctx.actor = nfsd4_build_namelist,
|
.ctx.actor = nfsd4_build_namelist,
|
||||||
.names = LIST_HEAD_INIT(ctx.names)
|
.names = LIST_HEAD_INIT(ctx.names)
|
||||||
};
|
};
|
||||||
|
struct name_list *entry, *tmp;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = nfs4_save_creds(&original_cred);
|
status = nfs4_save_creds(&original_cred);
|
||||||
@ -286,9 +287,8 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
|
|||||||
|
|
||||||
status = iterate_dir(nn->rec_file, &ctx.ctx);
|
status = iterate_dir(nn->rec_file, &ctx.ctx);
|
||||||
mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
|
mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
|
||||||
while (!list_empty(&ctx.names)) {
|
|
||||||
struct name_list *entry;
|
list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
|
||||||
entry = list_entry(ctx.names.next, struct name_list, list);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1);
|
dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1);
|
||||||
@ -304,6 +304,12 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
|
|||||||
}
|
}
|
||||||
mutex_unlock(&d_inode(dir)->i_mutex);
|
mutex_unlock(&d_inode(dir)->i_mutex);
|
||||||
nfs4_reset_creds(original_cred);
|
nfs4_reset_creds(original_cred);
|
||||||
|
|
||||||
|
list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
|
||||||
|
dprintk("NFSD: %s. Left entry %s\n", __func__, entry->name);
|
||||||
|
list_del(&entry->list);
|
||||||
|
kfree(entry);
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user