]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
phy: zynqmp: fix runtime PM leak on probe allocation failure
authorRadhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Mon, 20 Jul 2026 15:38:31 +0000 (21:08 +0530)
committerVinod Koul <vkoul@kernel.org>
Wed, 22 Jul 2026 08:22:28 +0000 (13:52 +0530)
Allocate saved_regs before pm_runtime_resume_and_get() so a
devm_kmalloc() failure does not leave an unreleased runtime PM usage
counter.

Fixes: 5af9b304bc60 ("phy: xilinx: phy-zynqmp: Fix SGMII linkup failure on resume")
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Link: https://patch.msgid.link/20260720153832.1130006-3-radhey.shyam.pandey@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/phy/xilinx/phy-zynqmp.c

index c8230f2bda6290910bd934d84912b7309c1505ad..2138f5399821a95798e4a2783143587aaf22d5bc 100644 (file)
@@ -1044,6 +1044,12 @@ static int xpsgtr_probe(struct platform_device *pdev)
                return PTR_ERR(provider);
        }
 
+       gtr_dev->saved_regs = devm_kmalloc(gtr_dev->dev,
+                                          sizeof(save_reg_address),
+                                          GFP_KERNEL);
+       if (!gtr_dev->saved_regs)
+               return -ENOMEM;
+
        pm_runtime_set_active(gtr_dev->dev);
        pm_runtime_enable(gtr_dev->dev);
 
@@ -1053,12 +1059,6 @@ static int xpsgtr_probe(struct platform_device *pdev)
                return ret;
        }
 
-       gtr_dev->saved_regs = devm_kmalloc(gtr_dev->dev,
-                                          sizeof(save_reg_address),
-                                          GFP_KERNEL);
-       if (!gtr_dev->saved_regs)
-               return -ENOMEM;
-
        return 0;
 }