]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
phy: Fix error handling in tegra_xusb_port_init
authorMa Ke <make24@iscas.ac.cn>
Mon, 3 Mar 2025 07:27:39 +0000 (15:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 May 2025 12:12:22 +0000 (14:12 +0200)
commit2b169aa46f97080ae87cbd3a4b99c7b127901d2a
treed7d41f3c684042a8c5dee846c217cc82e4a0d636
parentba25131b3c1ceec303839b2462586d7673788197
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>
drivers/phy/tegra/xusb.c