phy: tegra: xusb: fix error handing in tegra_xusb_{pad|port}_init()
PATCH 1/1 phy: tegra: xusb: fix error handing in tegra_xusb_{pad|port}_init()
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 <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Cc Vinod Koul <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Jonathan Hunter <[email protected]>
Signed-off-by Yang Yingliang <[email protected]>
--- drivers/phy/tegra/xusb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/phy/tegra/xusb.c +8 -8
@@ -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; }
Signature · 1 line
2.25.1