The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net] wan: wanxl: Only reset hardware after BAR mapping
@ 2026-07-08 14:34 Ruoyu Wang
  2026-07-21 11:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-07-08 14:34 UTC (permalink / raw)
  To: khc, andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Ruoyu Wang

wanxl_pci_init_one() stores the freshly allocated card in driver data
before the PLX BAR is mapped.  Several early probe failures then unwind
through wanxl_pci_remove_one(), including failure to allocate the coherent
status area or to restore the DMA mask.

wanxl_pci_remove_one() unconditionally calls wanxl_reset(), and
wanxl_reset() dereferences card->plx.  On those early failures card->plx
is still NULL, so the error path can dereference a NULL MMIO pointer.

Only issue the hardware reset once the BAR mapping exists.  The remaining
cleanup in wanxl_pci_remove_one() already checks whether later resources
were allocated.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/net/wan/wanxl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index d4da88c771129..065c00c12cc16 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -514,7 +514,8 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)
 	if (card->irq)
 		free_irq(card->irq, card);
 
-	wanxl_reset(card);
+	if (card->plx)
+		wanxl_reset(card);
 
 	for (i = 0; i < RX_QUEUE_LENGTH; i++)
 		if (card->rx_skbs[i]) {
-- 
2.51.0


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

* Re: [PATCH net] wan: wanxl: Only reset hardware after BAR mapping
  2026-07-08 14:34 [PATCH net] wan: wanxl: Only reset hardware after BAR mapping Ruoyu Wang
@ 2026-07-21 11:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-21 11:20 UTC (permalink / raw)
  To: Ruoyu Wang
  Cc: khc, andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed,  8 Jul 2026 22:34:15 +0800 you wrote:
> wanxl_pci_init_one() stores the freshly allocated card in driver data
> before the PLX BAR is mapped.  Several early probe failures then unwind
> through wanxl_pci_remove_one(), including failure to allocate the coherent
> status area or to restore the DMA mask.
> 
> wanxl_pci_remove_one() unconditionally calls wanxl_reset(), and
> wanxl_reset() dereferences card->plx.  On those early failures card->plx
> is still NULL, so the error path can dereference a NULL MMIO pointer.
> 
> [...]

Here is the summary with links:
  - [net] wan: wanxl: Only reset hardware after BAR mapping
    https://git.kernel.org/netdev/net/c/91957b89da99

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-07-21 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 14:34 [PATCH net] wan: wanxl: Only reset hardware after BAR mapping Ruoyu Wang
2026-07-21 11:20 ` patchwork-bot+netdevbpf

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