[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241014073038.27215-3-danielyangkang@gmail.com>
Date: Mon, 14 Oct 2024 00:30:38 -0700
From: Daniel Yang <danielyangkang@...il.com>
To: Wenjia Zhang <wenjia@...ux.ibm.com>,
Jan Karcher <jaka@...ux.ibm.com>,
"D. Wythe" <alibuda@...ux.alibaba.com>,
Tony Lu <tonylu@...ux.alibaba.com>,
Wen Gu <guwen@...ux.alibaba.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
linux-s390@...r.kernel.org,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: danielyangkang@...il.com,
syzbot+e953a8f3071f5c0a28fd@...kaller.appspotmail.com
Subject: [PATCH v3 2/2] Move lockdep annotation to separate function for readability.
From: Daniel Yang <danielyangkang@...il.com>
Moved lockdep annotation to separate function for readability.
Signed-off-by: Daniel Yang <danielyangkang@...il.com>
Reported-by: syzbot+e953a8f3071f5c0a28fd@...kaller.appspotmail.com
---
net/smc/smc_inet.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/net/smc/smc_inet.c b/net/smc/smc_inet.c
index 7ae49ffd2..b3eedc3b0 100644
--- a/net/smc/smc_inet.c
+++ b/net/smc/smc_inet.c
@@ -111,18 +111,7 @@ static struct inet_protosw smc_inet6_protosw = {
static struct lock_class_key smc_slock_keys[2];
static struct lock_class_key smc_keys[2];
-static int smc_inet_init_sock(struct sock *sk)
-{
- struct net *net = sock_net(sk);
- int rc;
-
- /* init common smc sock */
- smc_sk_init(net, sk, IPPROTO_SMC);
- /* create clcsock */
- rc = smc_create_clcsk(net, sk, sk->sk_family);
- if (rc)
- return rc;
-
+static inline void smc_inet_lockdep_annotate(struct sock *sk)
+{
switch (sk->sk_family) {
case AF_INET:
sock_lock_init_class_and_name(sk, "slock-AF_INET-SMC",
@@ -139,8 +128,21 @@ static int smc_inet_init_sock(struct sock *sk)
default:
WARN_ON_ONCE(1);
}
+}
- return 0;
+static int smc_inet_init_sock(struct sock *sk)
+{
+ struct net *net = sock_net(sk);
+ int rc;
+
+ /* init common smc sock */
+ smc_sk_init(net, sk, IPPROTO_SMC);
+ /* create clcsock */
+ rc = smc_create_clcsk(net, sk, sk->sk_family);
+ if (!rc)
+ smc_inet_lockdep_annotate(sk);
+
+ return rc;
}
int __init smc_inet_init(void)
--
2.39.2
Powered by blists - more mailing lists