summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2008-10-16 14:15:16 +1100
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-10-17 13:06:45 -0400
commit504e518953a330c8d44a95bdd65a5c9f50f1012e (patch)
tree383df8cd12bebecd9bcf7714b6d8b07324a6353f /include
parent18de9735300756e3ca9c361ef58409d8561dfe0d (diff)
downloadop-kernel-dev-504e518953a330c8d44a95bdd65a5c9f50f1012e.zip
op-kernel-dev-504e518953a330c8d44a95bdd65a5c9f50f1012e.tar.gz
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>
Diffstat (limited to 'include')
-rw-r--r--include/linux/nfs_fs.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index ac8d023..4eaa834 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -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;
}
OpenPOWER on IntegriCloud