diff mbox series

[SRU,Kinetic,Lunar,3/3] (upstream) NFS: Fix up a sparse warning

Message ID 20230118145737.36068-4-chengen.du@canonical.com
State New
Headers show
Series NFS: client permission error after adding user to permissible group | expand

Commit Message

Chengen Du Jan. 18, 2023, 2:57 p.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

BugLink: https://bugs.launchpad.net/bugs/2003053

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>
(cherry picked from commit 5e9a7b9c2ea18551759833146a181b14835bfe39)
Signed-off-by: Chengen Du <chengen.du@canonical.com>
---
 fs/nfs/dir.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 691ad507841c..881a8301ccac 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2910,12 +2910,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;
 	}