Skip to content

Commit

Permalink
NFS: Ensure rpc_run_task() cannot fail in nfs_async_rename()
Browse files Browse the repository at this point in the history
Ensure the call to rpc_run_task() cannot fail by preallocating the
rpc_task.

Fixes: 910ad38 ("NFS: Fix memory allocation in rpc_alloc_task()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Apr 7, 2022
1 parent 68b78dc commit 88dee0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions fs/nfs/unlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir,
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL)
return ERR_PTR(-ENOMEM);
task_setup_data.task = &data->task;
task_setup_data.callback_data = data;

data->cred = get_current_cred();
Expand Down
1 change: 1 addition & 0 deletions include/linux/nfs_xdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ struct nfs_unlinkdata {
struct nfs_renamedata {
struct nfs_renameargs args;
struct nfs_renameres res;
struct rpc_task task;
const struct cred *cred;
struct inode *old_dir;
struct dentry *old_dentry;
Expand Down

0 comments on commit 88dee0c

Please sign in to comment.