net: sxgbe: handle descriptor ring allocation failures
Subsystems (3)
PATCH 3/7 net: sxgbe: handle descriptor ring allocation failures
From: Chenguang Zhao <[email protected]>
sxgbe_open() ignores allocation failures and proceeds to program DMA with invalid ring addresses. In addition, an RX allocation failure leaks all TX descriptor rings allocated earlier. Check the return value and unwind both ring types before disconnecting the PHY.
--- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +7 -1
@@ -605,6 +605,9 @@ static int init_dma_desc_rings(struct net_device *netd) rxalloc_err:while (queue_num--)free_rx_ring (priv->device, priv->rxq[queue_num], rx_rsize); + queue_num =SXGBE_TX_QUEUES ; +while (queue_num--) +free_tx_ring (priv->device, priv->txq[queue_num], tx_rsize);return ret; }
@@ -1079,7 +1082,9 @@ static int sxgbe_open(struct net_device *dev) priv->dma_buf_sz =SXGBE_ALIGN (DMA_BUFFER_SIZE ); priv->tx_tc =TC_DEFAULT ; priv->rx_tc =TC_DEFAULT ; -init_dma_desc_rings (dev); + ret =init_dma_desc_rings (dev); +if (ret) + goto init_phy_error;/* DMA initialization and SW reset */ ret =sxgbe_init_dma_engine (priv);
@@ -1188,6 +1193,7 @@ static int sxgbe_open(struct net_device *dev) init_error:free_dma_desc_resources (priv); +init_phy_error:if (dev->phydev)phy_disconnect (dev->phydev); phy_error:
Signature · 1 line
2.25.1
Quoted 6 lines · Chenguang Zhao
From: Chenguang Zhao <[email protected]>
sxgbe_open()ignores allocation failures and proceeds to program DMA with invalid ring addresses. In addition, an RX allocation failure leaks all TX descriptor rings allocated earlier. Check the return value and unwind both ring types before disconnecting the PHY.
You are fixing two things here, so there should be two patches. We want lots of small patches which are obviously correct, with good commit messages. And if your change breaks something, a git bisect gives more information.
Andrew
---
pw-bot: cr