[PATCH net] net: pch_gbe: Propagate device restart errors from resume
From: Pengpeng Hou
Date: Fri Aug 28 2026 - 06:58:11 EST
pch_gbe_up() can fail while allocating the IRQ or receive and transmit
buffers. The resume path ignores that result and attaches the netdevice
even though restart did not complete.
Return the restart error, leave the netdevice detached, and restore the
PHY and PCI device to the suspended resource state. pch_gbe_up()
already frees allocations made before its failure.
The issue was identified via static analysis and manually reviewed.
Fixes: 77555ee72282 ("net: Add Gigabit Ethernet driver of Topcliff PCH")
Assisted-by: LLM
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 88c5c52e0e38..737bdc9d569e 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2449,7 +2449,7 @@ static int pch_gbe_resume(struct device *device)
struct net_device *netdev = pci_get_drvdata(pdev);
struct pch_gbe_adapter *adapter = netdev_priv(netdev);
struct pch_gbe_hw *hw = &adapter->hw;
- u32 err;
+ int err;
err = pci_enable_device(pdev);
if (err) {
@@ -2462,8 +2462,14 @@ static int pch_gbe_resume(struct device *device)
/* Clear wake on lan control and status */
pch_gbe_mac_set_wol_event(hw, 0);
- if (netif_running(netdev))
- pch_gbe_up(adapter);
+ if (netif_running(netdev)) {
+ err = pch_gbe_up(adapter);
+ if (err) {
+ pch_gbe_phy_power_down(hw);
+ pci_disable_device(pdev);
+ return err;
+ }
+ }
netif_device_attach(netdev);
return 0;
--
2.43.0