]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wan: wanxl: Only reset hardware after BAR mapping
authorRuoyu Wang <ruoyuw560@gmail.com>
Wed, 8 Jul 2026 14:34:15 +0000 (22:34 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 21 Jul 2026 11:12:43 +0000 (13:12 +0200)
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>
Link: https://patch.msgid.link/20260708143415.3169358-1-ruoyuw560@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/wan/wanxl.c

index d4da88c7711291a62143b5c9df0b9cc12a466cf6..065c00c12cc1689badd1bf9c7e67216227a69298 100644 (file)
@@ -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]) {