@@ -3624,8 +3624,14 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
3624
3624
else
3625
3625
bond_xmit_slave_id (bond , skb , 0 );
3626
3626
} else {
3627
- slave_id = bond_rr_gen_slave_id (bond );
3628
- bond_xmit_slave_id (bond , skb , slave_id % bond -> slave_cnt );
3627
+ int slave_cnt = ACCESS_ONCE (bond -> slave_cnt );
3628
+
3629
+ if (likely (slave_cnt )) {
3630
+ slave_id = bond_rr_gen_slave_id (bond );
3631
+ bond_xmit_slave_id (bond , skb , slave_id % slave_cnt );
3632
+ } else {
3633
+ dev_kfree_skb_any (skb );
3634
+ }
3629
3635
}
3630
3636
3631
3637
return NETDEV_TX_OK ;
@@ -3656,8 +3662,13 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
3656
3662
static int bond_xmit_xor (struct sk_buff * skb , struct net_device * bond_dev )
3657
3663
{
3658
3664
struct bonding * bond = netdev_priv (bond_dev );
3665
+ int slave_cnt = ACCESS_ONCE (bond -> slave_cnt );
3659
3666
3660
- bond_xmit_slave_id (bond , skb , bond_xmit_hash (bond , skb , bond -> slave_cnt ));
3667
+ if (likely (slave_cnt ))
3668
+ bond_xmit_slave_id (bond , skb ,
3669
+ bond_xmit_hash (bond , skb , bond -> slave_cnt ));
3670
+ else
3671
+ dev_kfree_skb_any (skb );
3661
3672
3662
3673
return NETDEV_TX_OK ;
3663
3674
}
0 commit comments