1
0
Fork 0

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: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
hifive-unleashed-5.1
Neil Brown 2008-10-16 14:15:16 +11:00 committed by Trond Myklebust
parent 18de973530
commit 504e518953
2 changed files with 10 additions and 4 deletions

View File

@ -1659,8 +1659,10 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
struct nfs_open_context *ctx;
ctx = nfs_file_open_context(sattr->ia_file);
cred = ctx->cred;
state = ctx->state;
if (ctx) {
cred = ctx->cred;
state = ctx->state;
}
}
status = nfs4_do_setattr(inode, cred, fattr, sattr, state);

View File

@ -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)
{
if (file != NULL)
return nfs_file_open_context(file)->cred;
if (file != NULL) {
struct nfs_open_context *ctx =
nfs_file_open_context(file);
if (ctx)
return ctx->cred;
}
return NULL;
}