aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorMitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>2011-10-12 12:04:29 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-19 00:14:22 -0400
commit4d97480b1806e883eb1c7889d4e7a87e936e06d9 (patch)
tree0a690a2f5718826eb871ad655c9acddb5b84f335 /drivers/net/bonding/bond_main.c
parent28c213793c994e4aac5f669ce856b5682a549bbb (diff)
bonding: use local function pointer of bond->recv_probe in bond_handle_frame
The bond->recv_probe is called in bond_handle_frame() when a packet is received, but bond_close() sets it to NULL. So, a panic occurs when both functions work in parallel. Why this happen: After null pointer check of bond->recv_probe, an sk_buff is duplicated and bond->recv_probe is called in bond_handle_frame. So, a panic occurs when bond_close() is called between the check and call of bond->recv_probe. Patch: This patch uses a local function pointer of bond->recv_probe in bond_handle_frame(). So, it can avoid the null pointer dereference. Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com> Cc: Jay Vosburgh <fubar@us.ibm.com> Cc: Andy Gospodarek <andy@greyhouse.net> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: WANG Cong <xiyou.wangcong@gmail.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6d79b78cfc75..de3d351ccb6b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1435,6 +1435,8 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
1435 struct sk_buff *skb = *pskb; 1435 struct sk_buff *skb = *pskb;
1436 struct slave *slave; 1436 struct slave *slave;
1437 struct bonding *bond; 1437 struct bonding *bond;
1438 void (*recv_probe)(struct sk_buff *, struct bonding *,
1439 struct slave *);
1438 1440
1439 skb = skb_share_check(skb, GFP_ATOMIC); 1441 skb = skb_share_check(skb, GFP_ATOMIC);
1440 if (unlikely(!skb)) 1442 if (unlikely(!skb))
@@ -1448,11 +1450,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
1448 if (bond->params.arp_interval) 1450 if (bond->params.arp_interval)
1449 slave->dev->last_rx = jiffies; 1451 slave->dev->last_rx = jiffies;
1450 1452
1451 if (bond->recv_probe) { 1453 recv_probe = ACCESS_ONCE(bond->recv_probe);
1454 if (recv_probe) {
1452 struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); 1455 struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
1453 1456
1454 if (likely(nskb)) { 1457 if (likely(nskb)) {
1455 bond->recv_probe(nskb, bond, slave); 1458 recv_probe(nskb, bond, slave);
1456 dev_kfree_skb(nskb); 1459 dev_kfree_skb(nskb);
1457 } 1460 }
1458 } 1461 }