Re: [PATCH 2/3] nfsd: Fix a memory leak in nfsd4_list_rec_dir()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 07, 2015 at 10:13:02AM +0800, Kinglong Mee wrote:
> If lookup_one_len() failed, nfsd should free those memory allocated for fname.

Thanks, applying for 4.3.

--b.

> 
> Signed-off-by: Kinglong Mee <kinglongmee@xxxxxxxxx>
> ---
>  fs/nfsd/nfs4recover.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
> index d88ea7b..591bfbd 100644
> --- a/fs/nfsd/nfs4recover.c
> +++ b/fs/nfsd/nfs4recover.c
> @@ -272,6 +272,7 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
>  		.ctx.actor = nfsd4_build_namelist,
>  		.names = LIST_HEAD_INIT(ctx.names)
>  	};
> +	struct name_list *entry, *tmp;
>  	int status;
>  
>  	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);
>  	mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
> -	while (!list_empty(&ctx.names)) {
> -		struct name_list *entry;
> -		entry = list_entry(ctx.names.next, struct name_list, list);
> +
> +	list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
>  		if (!status) {
>  			struct dentry *dentry;
>  			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);
>  	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;
>  }
>  
> -- 
> 2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux