Commit 504e5189 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

Make nfs_file_cred more robust.

As not all files have an associated open_context (e.g. device special
files), it is safest to test for the existence of the open context
before de-referencing it.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 18de9735
...@@ -1659,8 +1659,10 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, ...@@ -1659,8 +1659,10 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
struct nfs_open_context *ctx; struct nfs_open_context *ctx;
ctx = nfs_file_open_context(sattr->ia_file); ctx = nfs_file_open_context(sattr->ia_file);
cred = ctx->cred; if (ctx) {
state = ctx->state; cred = ctx->cred;
state = ctx->state;
}
} }
status = nfs4_do_setattr(inode, cred, fattr, sattr, state); status = nfs4_do_setattr(inode, cred, fattr, sattr, state);
......
...@@ -367,8 +367,12 @@ static inline struct nfs_open_context *nfs_file_open_context(struct file *filp) ...@@ -367,8 +367,12 @@ static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
static inline struct rpc_cred *nfs_file_cred(struct file *file) static inline struct rpc_cred *nfs_file_cred(struct file *file)
{ {
if (file != NULL) if (file != NULL) {
return nfs_file_open_context(file)->cred; struct nfs_open_context *ctx =
nfs_file_open_context(file);
if (ctx)
return ctx->cred;
}
return NULL; return NULL;
} }
......
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