NFS: Fix up a sparse warning
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 2 Jan 2023 01:17:23 +0000 (20:17 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 2 Jan 2023 01:17:26 +0000 (20:17 -0500)
sparse is warning about an incorrect RCU dereference.
fs/nfs/dir.c:2965:56: warning: incorrect type in argument 1 (different address spaces)
fs/nfs/dir.c:2965:56:    expected struct cred const *
fs/nfs/dir.c:2965:56:    got struct cred const [noderef] __rcu *const cred

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/dir.c

index d490d64a9ebd05c40e3c4ca613cdd7d577c6f758..f7e4a88d5d92928a60858308cac312f87632d0bd 100644 (file)
@@ -2957,12 +2957,14 @@ static u64 nfs_access_login_time(const struct task_struct *task,
                                 const struct cred *cred)
 {
        const struct task_struct *parent;
+       const struct cred *pcred;
        u64 ret;
 
        rcu_read_lock();
        for (;;) {
                parent = rcu_dereference(task->real_parent);
-               if (parent == task || cred_fscmp(parent->cred, cred) != 0)
+               pcred = rcu_dereference(parent->cred);
+               if (parent == task || cred_fscmp(pcred, cred) != 0)
                        break;
                task = parent;
        }