mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure
[ Upstream commitd68cb7cf1f] Do skb_put() after a new skb has been successfully allocated otherwise the reused skb leads to skb_panics or incorrect packet sizes. Fixes:f92e1869d7("Add Mellanox BlueField Gigabit Ethernet driver") Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/r/20230524194908.147145-1-tbogendoerfer@suse.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
724aa4fd9e
commit
ae0ef97f1e
@@ -245,12 +245,6 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
|
|||||||
|
|
||||||
skb = priv->rx_skb[rx_pi_rem];
|
skb = priv->rx_skb[rx_pi_rem];
|
||||||
|
|
||||||
skb_put(skb, datalen);
|
|
||||||
|
|
||||||
skb->ip_summed = CHECKSUM_NONE; /* device did not checksum packet */
|
|
||||||
|
|
||||||
skb->protocol = eth_type_trans(skb, netdev);
|
|
||||||
|
|
||||||
/* Alloc another RX SKB for this same index */
|
/* Alloc another RX SKB for this same index */
|
||||||
rx_skb = mlxbf_gige_alloc_skb(priv, MLXBF_GIGE_DEFAULT_BUF_SZ,
|
rx_skb = mlxbf_gige_alloc_skb(priv, MLXBF_GIGE_DEFAULT_BUF_SZ,
|
||||||
&rx_buf_dma, DMA_FROM_DEVICE);
|
&rx_buf_dma, DMA_FROM_DEVICE);
|
||||||
@@ -259,6 +253,13 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
|
|||||||
priv->rx_skb[rx_pi_rem] = rx_skb;
|
priv->rx_skb[rx_pi_rem] = rx_skb;
|
||||||
dma_unmap_single(priv->dev, *rx_wqe_addr,
|
dma_unmap_single(priv->dev, *rx_wqe_addr,
|
||||||
MLXBF_GIGE_DEFAULT_BUF_SZ, DMA_FROM_DEVICE);
|
MLXBF_GIGE_DEFAULT_BUF_SZ, DMA_FROM_DEVICE);
|
||||||
|
|
||||||
|
skb_put(skb, datalen);
|
||||||
|
|
||||||
|
skb->ip_summed = CHECKSUM_NONE; /* device did not checksum packet */
|
||||||
|
|
||||||
|
skb->protocol = eth_type_trans(skb, netdev);
|
||||||
|
|
||||||
*rx_wqe_addr = rx_buf_dma;
|
*rx_wqe_addr = rx_buf_dma;
|
||||||
} else if (rx_cqe & MLXBF_GIGE_RX_CQE_PKT_STATUS_MAC_ERR) {
|
} else if (rx_cqe & MLXBF_GIGE_RX_CQE_PKT_STATUS_MAC_ERR) {
|
||||||
priv->stats.rx_mac_errors++;
|
priv->stats.rx_mac_errors++;
|
||||||
|
|||||||
Reference in New Issue
Block a user