Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

batman-adv: adopt netdev_hold() / netdev_put()

Add a device tracker to struct batadv_hard_iface to help
debugging of network device refcount imbalances.

Signed-off-by: Eric Dumazet <edumazet@google.com>
[sven@narfation.org: fix kernel-doc, adopt for softif reference]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>

authored by

Eric Dumazet and committed by
Simon Wunderlich
00b35530 9a006e72

+14 -12
+8 -12
net/batman-adv/hard-interface.c
··· 51 51 struct batadv_hard_iface *hard_iface; 52 52 53 53 hard_iface = container_of(ref, struct batadv_hard_iface, refcount); 54 - dev_put(hard_iface->net_dev); 54 + netdev_put(hard_iface->net_dev, &hard_iface->dev_tracker); 55 55 56 56 kfree_rcu(hard_iface, rcu); 57 57 } ··· 728 728 kref_get(&hard_iface->refcount); 729 729 730 730 dev_hold(soft_iface); 731 + netdev_hold(soft_iface, &hard_iface->softif_dev_tracker, GFP_ATOMIC); 731 732 hard_iface->soft_iface = soft_iface; 732 733 bat_priv = netdev_priv(hard_iface->soft_iface); 733 734 ··· 785 784 netdev_upper_dev_unlink(hard_iface->net_dev, soft_iface); 786 785 err_dev: 787 786 hard_iface->soft_iface = NULL; 788 - dev_put(soft_iface); 787 + netdev_put(soft_iface, &hard_iface->softif_dev_tracker); 789 788 batadv_hardif_put(hard_iface); 790 789 return ret; 791 790 } ··· 852 851 /* delete all references to this hard_iface */ 853 852 batadv_purge_orig_ref(bat_priv); 854 853 batadv_purge_outstanding_packets(bat_priv, hard_iface); 855 - dev_put(hard_iface->soft_iface); 854 + netdev_put(hard_iface->soft_iface, &hard_iface->softif_dev_tracker); 856 855 857 856 netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface); 858 857 batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface); ··· 876 875 ASSERT_RTNL(); 877 876 878 877 if (!batadv_is_valid_iface(net_dev)) 879 - goto out; 880 - 881 - dev_hold(net_dev); 878 + return NULL; 882 879 883 880 hard_iface = kzalloc(sizeof(*hard_iface), GFP_ATOMIC); 884 881 if (!hard_iface) 885 - goto release_dev; 882 + return NULL; 886 883 884 + netdev_hold(net_dev, &hard_iface->dev_tracker, GFP_ATOMIC); 887 885 hard_iface->net_dev = net_dev; 886 + 888 887 hard_iface->soft_iface = NULL; 889 888 hard_iface->if_status = BATADV_IF_NOT_IN_USE; 890 889 ··· 910 909 batadv_hardif_generation++; 911 910 912 911 return hard_iface; 913 - 914 - release_dev: 915 - dev_put(net_dev); 916 - out: 917 - return NULL; 918 912 } 919 913 920 914 static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface)
+6
net/batman-adv/types.h
··· 186 186 /** @net_dev: pointer to the net_device */ 187 187 struct net_device *net_dev; 188 188 189 + /** @dev_tracker: device tracker for @net_dev */ 190 + netdevice_tracker dev_tracker; 191 + 189 192 /** @refcount: number of contexts the object is used */ 190 193 struct kref refcount; 191 194 ··· 203 200 * interface 204 201 */ 205 202 struct net_device *soft_iface; 203 + 204 + /** @softif_dev_tracker: device tracker for @soft_iface */ 205 + netdevice_tracker softif_dev_tracker; 206 206 207 207 /** @rcu: struct used for freeing in an RCU-safe manner */ 208 208 struct rcu_head rcu;