Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/2] 8139cp: fix two TX error handling bugs
@ 2026-07-17 10:37 Yun Lu
  2026-07-17 10:37 ` [PATCH 01/13] 8139cp: fix DMA mapping unwind on TX frag map failure Yun Lu
  2026-07-17 10:37 ` [PATCH 02/13] 8139cp: handle cp_init_rings() failure in cp_tx_timeout() Yun Lu
  0 siblings, 2 replies; 7+ messages in thread
From: Yun Lu @ 2026-07-17 10:37 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni; +Cc: netdev

From: Yun Lu <luyun@kylinos.cn>

Hi,

This short series fixes two bugs in the transmit error handling of
the 8139cp driver. Both are only reachable when DMA mapping or
memory allocation fails, but each can take the kernel down when
triggered.

The first patch rewrites the DMA mapping unwind in cp_start_xmit().
When mapping a TX fragment fails, the current helper unmaps the
stale address found in the not-yet-written head descriptor slot,
which is a double unmap of a previously completed mapping; the
fragment unmaps use sizes shifted by one slot; and the head buffer
mapping is never unmapped at all, leaking one DMA mapping per
failure.

The second patch makes cp_tx_timeout() handle cp_init_rings()
failure. If the RX buffer refill fails there, the ring is left
empty, but the driver restarts the hardware and schedules NAPI
anyway, so cp_rx_poll() dereferences a NULL rx_skb slot and hits
BUG_ON(!skb). Bail out and leave the device down until the next
open instead.

Thanks,
Yun

Yun Lu (2):
  8139cp: fix DMA mapping unwind on TX frag map failure
  8139cp: handle cp_init_rings() failure in cp_tx_timeout()

 drivers/net/ethernet/realtek/8139cp.c | 31 +++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-07-23 13:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17 10:37 [PATCH net 0/2] 8139cp: fix two TX error handling bugs Yun Lu
2026-07-17 10:37 ` [PATCH 01/13] 8139cp: fix DMA mapping unwind on TX frag map failure Yun Lu
2026-07-22  7:37   ` luyun
2026-07-22 19:43     ` Jakub Kicinski
2026-07-23  1:57       ` luyun
2026-07-23 13:32         ` Jakub Kicinski
2026-07-17 10:37 ` [PATCH 02/13] 8139cp: handle cp_init_rings() failure in cp_tx_timeout() Yun Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox