Skip to content

Commit

Permalink
net/mlx4_en: Fix panic on xmit while port is down
Browse files Browse the repository at this point in the history
When port is down, tx drop counter update is not needed.
Updating the counter in this case can cause a kernel
panic as when the port is down, ring can be NULL.

Fixes: 63a664b ("net/mlx4_en: fix tx_dropped bug")
Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Moshe Shemesh authored and David S. Miller committed Sep 12, 2016
1 parent 564ed9b commit 7a61fc8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/net/ethernet/mellanox/mlx4/en_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -818,15 +818,15 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
real_size = get_real_size(skb, shinfo, dev, &lso_header_size,
&inline_ok, &fragptr);
if (unlikely(!real_size))
goto tx_drop;
goto tx_drop_count;

/* Align descriptor to TXBB size */
desc_size = ALIGN(real_size, TXBB_SIZE);
nr_txbb = desc_size / TXBB_SIZE;
if (unlikely(nr_txbb > MAX_DESC_TXBBS)) {
if (netif_msg_tx_err(priv))
en_warn(priv, "Oversized header or SG list\n");
goto tx_drop;
goto tx_drop_count;
}

bf_ok = ring->bf_enabled;
Expand Down Expand Up @@ -1071,9 +1071,10 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
PCI_DMA_TODEVICE);
}

tx_drop_count:
ring->tx_dropped++;
tx_drop:
dev_kfree_skb_any(skb);
ring->tx_dropped++;
return NETDEV_TX_OK;
}

Expand Down Expand Up @@ -1106,7 +1107,7 @@ netdev_tx_t mlx4_en_xmit_frame(struct mlx4_en_rx_alloc *frame,
goto tx_drop;

if (mlx4_en_is_tx_ring_full(ring))
goto tx_drop;
goto tx_drop_count;

/* fetch ring->cons far ahead before needing it to avoid stall */
ring_cons = READ_ONCE(ring->cons);
Expand Down Expand Up @@ -1176,7 +1177,8 @@ netdev_tx_t mlx4_en_xmit_frame(struct mlx4_en_rx_alloc *frame,

return NETDEV_TX_OK;

tx_drop:
tx_drop_count:
ring->tx_dropped++;
tx_drop:
return NETDEV_TX_BUSY;
}

0 comments on commit 7a61fc8

Please sign in to comment.