[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260131123917.258229-1-salah.triki@gmail.com>
Date: Sat, 31 Jan 2026 13:39:17 +0100
From: Salah Triki <salah.triki@...il.com>
To: JC Kuo <jckuo@...dia.com>,
Vinod Koul <vkoul@...nel.org>,
Neil Armstrong <neil.armstrong@...aro.org>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>
Cc: linux-phy@...ts.infradead.org,
linux-tegra@...r.kernel.org,
linux-kernel@...r.kernel.org,
Salah Triki <salah.triki@...il.com>
Subject: [PATCH] phy: tegra: xusb: fix wrong cleanup function in tegra_xusb_pad_init()
In `tegra_xusb_pad_init()`, the code currently calls `device_unregister()`
if `dev_set_name()` or `device_add()` fails. This is technically incorrect.
`device_unregister()` is a combination of `device_del()` and `put_device()`
Calling `device_del()` is only valid if the device has been successfully
added to the system via `device_add()`. If `device_add()` fails or has not
been called yet, we must only use `put_device()` to drop the reference
count initialized by `device_initialize()`.
Fix this by calling `put_device()` instead of `device_unregister()` in the
error path.
Fixes: 53d2a715c2403 ("phy: Add Tegra XUSB pad controller support")
Signed-off-by: Salah Triki <salah.triki@...il.com>
---
drivers/phy/tegra/xusb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index c89df95aa6ca..2db5586401e5 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -180,7 +180,7 @@ int tegra_xusb_pad_init(struct tegra_xusb_pad *pad,
return 0;
unregister:
- device_unregister(&pad->dev);
+ put_device(&pad->dev);
return err;
}
--
2.43.0
Powered by blists - more mailing lists