diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2020-02-08 03:32:49 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-23 11:36:31 +0300 |
commit | 07cd4e8f745cab38a608d2aa04972adf2ea0c756 (patch) | |
tree | d15f4d1458f93b013a0bbd8445748c52f32da84a /fs/nfs/inode.c | |
parent | 66bfacd0f3021d9911a3bfc62d90ab7a1d207fa6 (diff) | |
download | linux-07cd4e8f745cab38a608d2aa04972adf2ea0c756.tar.xz |
NFS: alloc_nfs_open_context() must use the file cred when available
[ Upstream commit 1d179d6bd67369a52edea8562154b31ee20be1cc ]
If we're creating a nfs_open_context() for a specific file pointer,
we must use the cred assigned to that file.
Fixes: a52458b48af1 ("NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 2a03bfeec10a..3802c88e8372 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -959,16 +959,16 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct file *filp) { struct nfs_open_context *ctx; - const struct cred *cred = get_current_cred(); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); - if (!ctx) { - put_cred(cred); + if (!ctx) return ERR_PTR(-ENOMEM); - } nfs_sb_active(dentry->d_sb); ctx->dentry = dget(dentry); - ctx->cred = cred; + if (filp) + ctx->cred = get_cred(filp->f_cred); + else + ctx->cred = get_current_cred(); ctx->ll_cred = NULL; ctx->state = NULL; ctx->mode = f_mode; |