diff options
| author | Ma Ke <make24@iscas.ac.cn> | 2025-03-03 15:27:39 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-05-22 14:10:06 +0200 |
| commit | f774628bc1602a2b7395f1d5c9afc0de972ec7b9 (patch) | |
| tree | 51a8b7e40db3386f4f12c86ae10837ae2001bf61 /drivers/phy | |
| parent | 12ba469abe81c0d00b6cc5b31fee186f01c0a0b9 (diff) | |
| download | linux-f774628bc1602a2b7395f1d5c9afc0de972ec7b9.tar.gz linux-f774628bc1602a2b7395f1d5c9afc0de972ec7b9.tar.bz2 linux-f774628bc1602a2b7395f1d5c9afc0de972ec7b9.zip | |
phy: Fix error handling in tegra_xusb_port_init
commit b2ea5f49580c0762d17d80d8083cb89bc3acf74f upstream.
If device_add() fails, do not use device_unregister() for error
handling. device_unregister() consists two functions: device_del() and
put_device(). device_unregister() should only be called after
device_add() succeeded because device_del() undoes what device_add()
does if successful. Change device_unregister() to put_device() call
before returning from the function.
As comment of device_add() says, 'if device_add() succeeds, you should
call device_del() when you want to get rid of it. If device_add() has
not succeeded, use only put_device() to drop the reference count'.
Found by code review.
Cc: stable@vger.kernel.org
Fixes: 53d2a715c240 ("phy: Add Tegra XUSB pad controller support")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Acked-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20250303072739.3874987-1-make24@iscas.ac.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/phy')
| -rw-r--r-- | drivers/phy/tegra/xusb.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index dc22b1dd2c8b..e3acd40e7cbc 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -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_device; err = device_add(&port->dev); if (err < 0) - goto unregister; + goto put_device; return 0; -unregister: - device_unregister(&port->dev); +put_device: + put_device(&port->dev); return err; } |
