Blob Blame History Raw
From: "David S. Miller" <davem@davemloft.net>
Date: Sun, 8 Jul 2018 17:02:59 +0900
Subject: net: sched: Fix warnings from xchg() on RCU'd cookie pointer.
Patch-mainline: v4.19-rc1
Git-commit: 0dbc81eab4d13f6d295da69c00e6efee2427b55c
References: bsc#1109837

The kbuild test robot reports:

>> net/sched/act_api.c:71:15: sparse: incorrect type in initializer (different address spaces) @@    expected struct tc_cookie [noderef] <asn:4>*__ret @@    got [noderef] <asn:4>*__ret @@
   net/sched/act_api.c:71:15:    expected struct tc_cookie [noderef] <asn:4>*__ret
   net/sched/act_api.c:71:15:    got struct tc_cookie *new_cookie
>> net/sched/act_api.c:71:13: sparse: incorrect type in assignment (different address spaces) @@    expected struct tc_cookie *old @@    got struct tc_cookie [noderef] <struct tc_cookie *old @@
   net/sched/act_api.c:71:13:    expected struct tc_cookie *old
   net/sched/act_api.c:71:13:    got struct tc_cookie [noderef] <asn:4>*[assigned] __ret
>> net/sched/act_api.c:132:48: sparse: dereference of noderef expression

Handle this in the usual way by force casting away the __rcu annotation
when we are using xchg() on it.

Fixes: eec94fdb0480 ("net: sched: use rcu for action cookie update")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 net/sched/act_api.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -68,7 +68,7 @@ static void tcf_set_action_cookie(struct
 {
 	struct tc_cookie *old;
 
-	old = xchg(old_cookie, new_cookie);
+	old = xchg((__force struct tc_cookie **)old_cookie, new_cookie);
 	if (old)
 		call_rcu(&old->rcu, tcf_free_cookie_rcu);
 }