[PATCH] net/9p: Fix sparse rcu warnings in client.c

From: Alexander Kapshuk
Date: Thu Jun 18 2020 - 14:33:30 EST


Address sparse nonderef rcu warnings:
net/9p/client.c:790:17: warning: incorrect type in argument 1 (different address spaces)
net/9p/client.c:790:17: expected struct spinlock [usertype] *lock
net/9p/client.c:790:17: got struct spinlock [noderef] <asn:4> *
net/9p/client.c:792:48: warning: incorrect type in argument 1 (different address spaces)
net/9p/client.c:792:48: expected struct spinlock [usertype] *lock
net/9p/client.c:792:48: got struct spinlock [noderef] <asn:4> *
net/9p/client.c:872:17: warning: incorrect type in argument 1 (different address spaces)
net/9p/client.c:872:17: expected struct spinlock [usertype] *lock
net/9p/client.c:872:17: got struct spinlock [noderef] <asn:4> *
net/9p/client.c:874:48: warning: incorrect type in argument 1 (different address spaces)
net/9p/client.c:874:48: expected struct spinlock [usertype] *lock
net/9p/client.c:874:48: got struct spinlock [noderef] <asn:4> *

Signed-off-by: Alexander Kapshuk <alexander.kapshuk@xxxxxxxxx>
---
net/9p/client.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/net/9p/client.c b/net/9p/client.c
index fc1f3635e5dd..807e0e2e2e5a 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -787,9 +787,15 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
}
recalc_sigpending:
if (sigpending) {
- spin_lock_irqsave(&current->sighand->siglock, flags);
+ struct sighand_struct *sighand;
+ rcu_read_lock();
+ sighand = rcu_dereference(current->sighand);
+
+ spin_lock_irqsave(&sighand->siglock, flags);
recalc_sigpending();
- spin_unlock_irqrestore(&current->sighand->siglock, flags);
+ spin_unlock_irqrestore(&sighand->siglock, flags);
+
+ rcu_read_unlock();
}
if (err < 0)
goto reterr;
@@ -869,9 +875,15 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type,
}
recalc_sigpending:
if (sigpending) {
- spin_lock_irqsave(&current->sighand->siglock, flags);
+ struct sighand_struct *sighand;
+ rcu_read_lock();
+ sighand = rcu_dereference(current->sighand);
+
+ spin_lock_irqsave(&sighand->siglock, flags);
recalc_sigpending();
- spin_unlock_irqrestore(&current->sighand->siglock, flags);
+ spin_unlock_irqrestore(&sighand->siglock, flags);
+
+ rcu_read_unlock();
}
if (err < 0)
goto reterr;
--
2.27.0