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

net/hsr: using kfree_rcu() to simplify the code

The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Acked-by: Arvid Brodin <arvid.brodin@alten.se>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Wei Yongjun and committed by
David S. Miller
1aee6cc2 7271174f

+4 -9
+4 -9
net/hsr/hsr_framereg.c
··· 127 127 return 0; 128 128 } 129 129 130 - static void node_entry_reclaim(struct rcu_head *rh) 131 - { 132 - kfree(container_of(rh, struct node_entry, rcu_head)); 133 - } 134 - 135 130 136 131 /* Add/merge node to the database of nodes. 'skb' must contain an HSR 137 132 * supervision frame. ··· 170 175 if (node && !ether_addr_equal(node->MacAddressA, hsr_sp->MacAddressA)) { 171 176 /* Node has changed its AddrA, frame was received from SlaveB */ 172 177 list_del_rcu(&node->mac_list); 173 - call_rcu(&node->rcu_head, node_entry_reclaim); 178 + kfree_rcu(node, rcu_head); 174 179 node = NULL; 175 180 } 176 181 ··· 178 183 !ether_addr_equal(node->MacAddressB, hsr_ethsup->ethhdr.h_source)) { 179 184 /* Cables have been swapped */ 180 185 list_del_rcu(&node->mac_list); 181 - call_rcu(&node->rcu_head, node_entry_reclaim); 186 + kfree_rcu(node, rcu_head); 182 187 node = NULL; 183 188 } 184 189 ··· 187 192 !ether_addr_equal(node->MacAddressA, hsr_ethsup->ethhdr.h_source)) { 188 193 /* Cables have been swapped */ 189 194 list_del_rcu(&node->mac_list); 190 - call_rcu(&node->rcu_head, node_entry_reclaim); 195 + kfree_rcu(node, rcu_head); 191 196 node = NULL; 192 197 } 193 198 ··· 412 417 hsr_nl_nodedown(hsr_priv, node->MacAddressA); 413 418 list_del_rcu(&node->mac_list); 414 419 /* Note that we need to free this entry later: */ 415 - call_rcu(&node->rcu_head, node_entry_reclaim); 420 + kfree_rcu(node, rcu_head); 416 421 } 417 422 } 418 423 rcu_read_unlock();