diff mbox series

[1/2] phy: tegra: xusb: fix device release in tegra210_xusb_padctl_probe

Message ID 20241028-phy-tegra-xusb-tegra210-put_device-v1-1-28f74368c9ba@gmail.com
State New
Headers show
Series phy: tegra: xusb: fix device(_node) release in tegra210_xusb_padctl_probe | expand

Commit Message

Javier Carrasco Oct. 28, 2024, 10:33 p.m. UTC
A reference to a device acquired via of_find_device_by_node() needs
to be released when it is no longer required by decrementing its
refcount, which avoids leaking the resource.

Add the missing call to platform_device_put() as soon as 'pdev' is no
longer required.

Cc: stable@vger.kernel.org
Fixes: 2d1021487273 ("phy: tegra: xusb: Add wake/sleepwalk for Tegra210")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/phy/tegra/xusb-tegra210.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/phy/tegra/xusb-tegra210.c b/drivers/phy/tegra/xusb-tegra210.c
index ebc8a7e21a31..9c7fdd29b7c4 100644
--- a/drivers/phy/tegra/xusb-tegra210.c
+++ b/drivers/phy/tegra/xusb-tegra210.c
@@ -3169,13 +3169,17 @@  tegra210_xusb_padctl_probe(struct device *dev,
 		goto out;
 	}
 
-	if (!platform_get_drvdata(pdev))
+	if (!platform_get_drvdata(pdev)) {
+		platform_device_put(pdev);
 		return ERR_PTR(-EPROBE_DEFER);
+	}
 
 	padctl->regmap = dev_get_regmap(&pdev->dev, "usb_sleepwalk");
 	if (!padctl->regmap)
 		dev_info(dev, "failed to find PMC regmap\n");
 
+	platform_device_put(pdev);
+
 out:
 	return &padctl->base;
 }