Skip to content

Commit

Permalink
net: fix rcu access on phonet_routes
Browse files Browse the repository at this point in the history
-Add __rcu annotation on table to fix sparse warnings:
net/phonet/pn_dev.c:279:25: warning: incorrect type in assignment (different address spaces)
net/phonet/pn_dev.c:279:25:    expected struct net_device *<noident>
net/phonet/pn_dev.c:279:25:    got void [noderef] <asn:4>*<noident>
net/phonet/pn_dev.c:376:17: warning: incorrect type in assignment (different address spaces)
net/phonet/pn_dev.c:376:17:    expected struct net_device *volatile <noident>
net/phonet/pn_dev.c:376:17:    got struct net_device [noderef] <asn:4>*<noident>
net/phonet/pn_dev.c:392:17: warning: incorrect type in assignment (different address spaces)
net/phonet/pn_dev.c:392:17:    expected struct net_device *<noident>
net/phonet/pn_dev.c:392:17:    got void [noderef] <asn:4>*<noident>

-Access table with rcu_access_pointer (fixes the following sparse errors):
net/phonet/pn_dev.c:278:25: error: incompatible types in comparison expression (different address spaces)
net/phonet/pn_dev.c:391:17: error: incompatible types in comparison expression (different address spaces)

Suggested-by: Eric Dumazet <[email protected]>
Signed-off-by: Fabian Frederick <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Fabian Frederick authored and davem330 committed Oct 6, 2014
1 parent e91a159 commit 79952bc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/phonet/pn_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

struct phonet_routes {
struct mutex lock;
struct net_device *table[64];
struct net_device __rcu *table[64];
};

struct phonet_net {
Expand Down Expand Up @@ -275,7 +275,7 @@ static void phonet_route_autodel(struct net_device *dev)
bitmap_zero(deleted, 64);
mutex_lock(&pnn->routes.lock);
for (i = 0; i < 64; i++)
if (dev == pnn->routes.table[i]) {
if (rcu_access_pointer(pnn->routes.table[i]) == dev) {
RCU_INIT_POINTER(pnn->routes.table[i], NULL);
set_bit(i, deleted);
}
Expand Down Expand Up @@ -388,7 +388,7 @@ int phonet_route_del(struct net_device *dev, u8 daddr)

daddr = daddr >> 2;
mutex_lock(&routes->lock);
if (dev == routes->table[daddr])
if (rcu_access_pointer(routes->table[daddr]) == dev)
RCU_INIT_POINTER(routes->table[daddr], NULL);
else
dev = NULL;
Expand Down

0 comments on commit 79952bc

Please sign in to comment.