If device_add() is not called successful, it can not call device_unregister(), it will lead a kernel crash because of deleting not added device. Fix these by using put_device() instead. Fixes: 53d2a715c240 ("phy: Add Tegra XUSB pad controller support") Cc: JC Kuo <jckuo@xxxxxxxxxx> Cc: Kishon Vijay Abraham I <kishon@xxxxxx> Cc: Vinod Koul <vkoul@xxxxxxxxxx> Cc: Thierry Reding <thierry.reding@xxxxxxxxx> Cc: Jonathan Hunter <jonathanh@xxxxxxxxxx> Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> --- drivers/phy/tegra/xusb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index 95091876c422..65e15dcde02f 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -165,16 +165,16 @@ int tegra_xusb_pad_init(struct tegra_xusb_pad *pad, err = dev_set_name(&pad->dev, "%s", pad->soc->name); if (err < 0) - goto unregister; + goto put_dev; err = device_add(&pad->dev); if (err < 0) - goto unregister; + goto put_dev; return 0; -unregister: - device_unregister(&pad->dev); +put_dev: + put_device(&pad->dev); return err; } @@ -542,16 +542,16 @@ static int tegra_xusb_port_init(struct tegra_xusb_port *port, err = dev_set_name(&port->dev, "%s-%u", name, index); if (err < 0) - goto unregister; + goto put_dev; err = device_add(&port->dev); if (err < 0) - goto unregister; + goto put_dev; return 0; -unregister: - device_unregister(&port->dev); +put_dev: + put_device(&port->dev); return err; } -- 2.25.1