Skip to contentSkip to conversation

phy: tegra: xusb: fix wrong cleanup function in tegra_xusb_pad_init()

PATCH New Salah Triki 1 participant 1 message Jan 31

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/phy/tegra/xusb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/tegra/xusb.c +1 -1
index c89df95aa6ca..2db5586401e5 100644
@@ -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;
 }
 
Signature · 1 line
2.43.0