Make nfs_file_cred more robust.
[linux-2.6-block.git] / include / linux / nfs_fs.h
index ac8d0233b05c00650498f92750a1b0b8db994239..4eaa8347a0d9ce08d09c7bb8436642e92c35fd0c 100644 (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;
 }