uhdlc_suspend() detaches the netdev and disables NAPI before allocating
the parameter RAM backup. If that allocation fails, suspend returns
-ENOMEM with the interface still running but NAPI disabled. The PM core
does not call resume after a failed suspend, so a later close attempts to
disable NAPI again and can wait indefinitely.

Allocate the backup before changing the runtime state. An allocation
failure then leaves the interface attached and NAPI enabled.

Fixes: c19b6d246a35 ("drivers/net: support hdlc function for QE-UCC")
Cc: [email protected]
Reported-by: Jakub Kicinski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Co-developed-by: Ijae Kim <[email protected]>
Signed-off-by: Ijae Kim <[email protected]>
Signed-off-by: Myeonghun Pak <[email protected]>
---
 drivers/net/wan/fsl_ucc_hdlc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 82796452e54a2..596f4ef053636 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -888,6 +888,10 @@ static int uhdlc_suspend(struct device *dev)
        if (!netif_running(priv->ndev))
                return 0;
 
+       priv->ucc_pram_bak = kmalloc_obj(*priv->ucc_pram_bak);
+       if (!priv->ucc_pram_bak)
+               return -ENOMEM;
+
        netif_device_detach(priv->ndev);
        napi_disable(&priv->napi);
 
@@ -897,10 +901,6 @@ static int uhdlc_suspend(struct device *dev)
        priv->gumr = ioread32be(&uf_regs->gumr);
        priv->guemr = ioread8(&uf_regs->guemr);
 
-       priv->ucc_pram_bak = kmalloc_obj(*priv->ucc_pram_bak);
-       if (!priv->ucc_pram_bak)
-               return -ENOMEM;
-
        /* backup HDLC parameter */
        memcpy_fromio(priv->ucc_pram_bak, priv->ucc_pram,
                      sizeof(struct ucc_hdlc_param));
-- 
2.47.1

Reply via email to