From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH ipsec-next 2/6] xfrm: avoid rcu sparse warning
Date: Mon, 9 Jan 2017 14:20:46 +0100 [thread overview]
Message-ID: <1483968050-788-3-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1483968050-788-1-git-send-email-fw@strlen.de>
xfrm/xfrm_state.c:1973:21: error: incompatible types in comparison expression (different address spaces)
Harmless, but lets fix it to reduce the noise.
While at it, get rid of unneeded NULL check, its never hit:
net/ipv4/xfrm4_state.c: xfrm_state_register_afinfo(&xfrm4_state_afinfo);
net/ipv6/xfrm6_state.c: return xfrm_state_register_afinfo(&xfrm6_state_afinfo);
net/ipv6/xfrm6_state.c: xfrm_state_unregister_afinfo(&xfrm6_state_afinfo);
... are the only callsites.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/xfrm/xfrm_state.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 64e3c82eedf6..e3c15ad1b246 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1932,10 +1932,10 @@ EXPORT_SYMBOL(xfrm_unregister_km);
int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo)
{
int err = 0;
- if (unlikely(afinfo == NULL))
- return -EINVAL;
- if (unlikely(afinfo->family >= NPROTO))
+
+ if (WARN_ON(afinfo->family >= NPROTO))
return -EAFNOSUPPORT;
+
spin_lock_bh(&xfrm_state_afinfo_lock);
if (unlikely(xfrm_state_afinfo[afinfo->family] != NULL))
err = -EEXIST;
@@ -1948,14 +1948,14 @@ EXPORT_SYMBOL(xfrm_state_register_afinfo);
int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo)
{
- int err = 0;
- if (unlikely(afinfo == NULL))
- return -EINVAL;
- if (unlikely(afinfo->family >= NPROTO))
+ int err = 0, family = afinfo->family;
+
+ if (WARN_ON(family >= NPROTO))
return -EAFNOSUPPORT;
+
spin_lock_bh(&xfrm_state_afinfo_lock);
if (likely(xfrm_state_afinfo[afinfo->family] != NULL)) {
- if (unlikely(xfrm_state_afinfo[afinfo->family] != afinfo))
+ if (rcu_access_pointer(xfrm_state_afinfo[family]) != afinfo)
err = -EINVAL;
else
RCU_INIT_POINTER(xfrm_state_afinfo[afinfo->family], NULL);
--
2.7.3
next prev parent reply other threads:[~2017-01-09 13:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-09 13:20 [PATCH ipsec-next 0/6] xfrm: remove xfrm_state_get_afinfo conditional rcu locking Florian Westphal
2017-01-09 13:20 ` [PATCH ipsec-next 1/6] xfrm: remove unused function Florian Westphal
2017-01-09 13:20 ` Florian Westphal [this message]
2017-01-09 13:20 ` [PATCH ipsec-next 3/6] xfrm: remove xfrm_state_put_afinfo Florian Westphal
2017-01-09 13:20 ` [PATCH ipsec-next 4/6] xfrm: add and use xfrm_state_afinfo_get_rcu Florian Westphal
2017-01-09 13:20 ` [PATCH ipsec-next 5/6] xfrm: state: simplify rcu_read_unlock handling in two spots Florian Westphal
2017-01-09 13:20 ` [PATCH ipsec-next 6/6] xfrm: remove xfrm_state_get_afinfo Florian Westphal
2017-01-11 12:17 ` [PATCH ipsec-next 0/6] xfrm: remove xfrm_state_get_afinfo conditional rcu locking Steffen Klassert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1483968050-788-3-git-send-email-fw@strlen.de \
--to=fw@strlen.de \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).