* [PATCH 3/7] net: sxgbe: handle descriptor ring allocation failures
@ 2026-07-20 2:47 Chenguang Zhao
2026-07-20 2:56 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Chenguang Zhao @ 2026-07-20 2:47 UTC (permalink / raw)
To: bh74.an, andrew+netdev, davem, edumazet, kuba, pabeni
Cc: netdev, chenguang.zhao, Chenguang Zhao
From: Chenguang Zhao <zhaochenguang@kylinos.cn>
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.
Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
---
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index 5051ada43d2f..8d9f27065346 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -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:
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/7] net: sxgbe: handle descriptor ring allocation failures
2026-07-20 2:47 [PATCH 3/7] net: sxgbe: handle descriptor ring allocation failures Chenguang Zhao
@ 2026-07-20 2:56 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2026-07-20 2:56 UTC (permalink / raw)
To: Chenguang Zhao
Cc: bh74.an, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
Chenguang Zhao
On Mon, Jul 20, 2026 at 10:47:47AM +0800, Chenguang Zhao wrote:
> From: Chenguang Zhao <zhaochenguang@kylinos.cn>
>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-20 2:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 2:47 [PATCH 3/7] net: sxgbe: handle descriptor ring allocation failures Chenguang Zhao
2026-07-20 2:56 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox