Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2638eb8b authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller
Browse files

net: ipv4: provide __rcu annotation for ifa_list



ifa_list is protected by rcu, yet code doesn't reflect this.

Add the __rcu annotations and fix up all places that are now reported by
sparse.

I've done this in the same commit to not add intermediate patches that
result in new warnings.

Reported-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb8f1478
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -174,10 +174,14 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,
		rcu_read_lock();
		in = __in_dev_get_rcu(upper_dev);

		if (!in->ifa_list)
		local_ipaddr = 0;
		else
			local_ipaddr = ntohl(in->ifa_list->ifa_address);
		if (in) {
			struct in_ifaddr *ifa;

			ifa = rcu_dereference(in->ifa_list);
			if (ifa)
				local_ipaddr = ntohl(ifa->ifa_address);
		}

		rcu_read_unlock();
	} else {
+7 −1
Original line number Diff line number Diff line
@@ -183,7 +183,13 @@ static int nes_inetaddr_event(struct notifier_block *notifier,

						rcu_read_lock();
						in = __in_dev_get_rcu(upper_dev);
						nesvnic->local_ipaddr = in->ifa_list->ifa_address;
						if (in) {
							struct in_ifaddr *ifa;

							ifa = rcu_dereference(in->ifa_list);
							if (ifa)
								nesvnic->local_ipaddr = ifa->ifa_address;
						}
						rcu_read_unlock();
					} else {
						nesvnic->local_ipaddr = ifa->ifa_address;
+10 −5
Original line number Diff line number Diff line
@@ -427,11 +427,16 @@ static void *usnic_ib_device_add(struct pci_dev *dev)
	if (netif_carrier_ok(us_ibdev->netdev))
		usnic_fwd_carrier_up(us_ibdev->ufdev);

	ind = in_dev_get(netdev);
	if (ind->ifa_list)
		usnic_fwd_add_ipaddr(us_ibdev->ufdev,
				     ind->ifa_list->ifa_address);
	in_dev_put(ind);
	rcu_read_lock();
	ind = __in_dev_get_rcu(netdev);
	if (ind) {
		const struct in_ifaddr *ifa;

		ifa = rcu_dereference(ind->ifa_list);
		if (ifa)
			usnic_fwd_add_ipaddr(us_ibdev->ufdev, ifa->ifa_address);
	}
	rcu_read_unlock();

	usnic_mac_ip_to_gid(us_ibdev->netdev->perm_addr,
				us_ibdev->ufdev->inaddr, &gid.raw[0]);
+1 −1
Original line number Diff line number Diff line
@@ -1509,7 +1509,7 @@ static inline int velocity_get_ip(struct velocity_info *vptr)
	rcu_read_lock();
	in_dev = __in_dev_get_rcu(vptr->netdev);
	if (in_dev != NULL) {
		ifa = (struct in_ifaddr *) in_dev->ifa_list;
		ifa = rcu_dereference(in_dev->ifa_list);
		if (ifa != NULL) {
			memcpy(vptr->ip_addr, &ifa->ifa_address, 4);
			res = 0;
+2 −2
Original line number Diff line number Diff line
@@ -1012,7 +1012,7 @@ plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
	in_dev = __in_dev_get_rcu(dev);
	if (in_dev) {
		/* Any address will do - we take the first */
		const struct in_ifaddr *ifa = in_dev->ifa_list;
		const struct in_ifaddr *ifa = rcu_dereference(in_dev->ifa_list);
		if (ifa) {
			memcpy(eth->h_source, dev->dev_addr, ETH_ALEN);
			memset(eth->h_dest, 0xfc, 2);
@@ -1107,7 +1107,7 @@ plip_open(struct net_device *dev)
		/* Any address will do - we take the first. We already
		   have the first two bytes filled with 0xfc, from
		   plip_init_dev(). */
		struct in_ifaddr *ifa=in_dev->ifa_list;
		const struct in_ifaddr *ifa = rcu_dereference(in_dev->ifa_list);
		if (ifa != NULL) {
			memcpy(dev->dev_addr+2, &ifa->ifa_local, 4);
		}
Loading