提交 dd5eede2 编写于 作者: J Jacob Keller 提交者: Jeff Kirsher

fm10k: avoid divide by zero in rare cases when device is resetting

It is possible that under rare circumstances the device is undergoing
a reset, such as when a PFLR occurs, and the device may be transmitting
simultaneously. In this case, we might attempt to divide by zero when
finding the proper r_idx. Instead, lets read the num_tx_queues once,
and make sure it's non-zero.
Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
Tested-by: NKrishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 d876c158
...@@ -643,9 +643,13 @@ int fm10k_close(struct net_device *netdev) ...@@ -643,9 +643,13 @@ int fm10k_close(struct net_device *netdev)
static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev) static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
{ {
struct fm10k_intfc *interface = netdev_priv(dev); struct fm10k_intfc *interface = netdev_priv(dev);
int num_tx_queues = READ_ONCE(interface->num_tx_queues);
unsigned int r_idx = skb->queue_mapping; unsigned int r_idx = skb->queue_mapping;
int err; int err;
if (!num_tx_queues)
return NETDEV_TX_BUSY;
if ((skb->protocol == htons(ETH_P_8021Q)) && if ((skb->protocol == htons(ETH_P_8021Q)) &&
!skb_vlan_tag_present(skb)) { !skb_vlan_tag_present(skb)) {
/* FM10K only supports hardware tagging, any tags in frame /* FM10K only supports hardware tagging, any tags in frame
...@@ -698,8 +702,8 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev) ...@@ -698,8 +702,8 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
__skb_put(skb, pad_len); __skb_put(skb, pad_len);
} }
if (r_idx >= interface->num_tx_queues) if (r_idx >= num_tx_queues)
r_idx %= interface->num_tx_queues; r_idx %= num_tx_queues;
err = fm10k_xmit_frame_ring(skb, interface->tx_ring[r_idx]); err = fm10k_xmit_frame_ring(skb, interface->tx_ring[r_idx]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册