Re: [PATCH v2] net: pch_gbe: handle TX skb allocation failure
From: Simon Horman
Date: Mon Jun 15 2026 - 07:24:05 EST
On Sat, Jun 13, 2026 at 04:00:43PM +0800, Ruoyu Wang wrote:
> pch_gbe_alloc_tx_buffers() allocates an skb for each TX descriptor and
> then passes the returned pointer to skb_reserve(). If netdev_alloc_skb()
> fails, skb_reserve() dereferences NULL.
>
> Make pch_gbe_alloc_tx_buffers() return an error when an skb allocation
> fails. On failure while bringing the device up, clean any TX buffers that
> were already allocated and release the RX buffer pool through a shared
> cleanup helper before unwinding the IRQ setup.
>
> Fixes: 77555ee72282 ("net: Add Gigabit Ethernet driver of Topcliff PCH")
> Signed-off-by: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
...
> @@ -1887,7 +1902,13 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
> "Error: can't bring device up - alloc rx buffers pool failed\n");
> goto freeirq;
> }
> - pch_gbe_alloc_tx_buffers(adapter, tx_ring);
> + err = pch_gbe_alloc_tx_buffers(adapter, tx_ring);
> + if (err) {
> + netdev_err(netdev,
> + "Error: can't bring device up - alloc tx buffers failed\n");
> + pch_gbe_clean_tx_ring(adapter, tx_ring);
I think that if pch_gbe_alloc_tx_buffers() fails then
it should handle cleaning up the ring buffer.
IOW, assuming it is safe to call pch_gbe_clean_tx_ring() like this,
I think that call belongs in error handling in pch_gbe_alloc_tx_buffers().
> + goto freebuf;
> + }
> pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
> adapter->tx_queue_len = netdev->tx_queue_len;
> pch_gbe_enable_dma_rx(&adapter->hw);
...