@@ -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;
}
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@nvidia.com> Cc: Kishon Vijay Abraham I <kishon@ti.com> Cc: Vinod Koul <vkoul@kernel.org> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Jonathan Hunter <jonathanh@nvidia.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/phy/tegra/xusb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)