phy: tegra: Fix regulator leak
authorThierry Reding <treding@nvidia.com>
Wed, 18 Mar 2020 22:25:54 +0000 (23:25 +0100)
committerThierry Reding <treding@nvidia.com>
Thu, 19 Mar 2020 13:00:04 +0000 (14:00 +0100)
commit2f8da84def73e1dd89385146e1dbb2ae2c8e0a6a
tree49393740be1a16f05e58d9aa54787616a0ea6784
parent562835644667459c701b08c036fbe72443a3fb71
phy: tegra: Fix regulator leak

Devices are created for each port of the XUSB pad controller. Each USB 2
and USB 3 port can potentially have an associated VBUS power supply that
needs to be removed when the device is removed.

Since port devices never bind to a driver, the driver core will not get
to perform the cleanup of device-managed resources that usually happens
on driver unbind.

Now, the driver core will also perform device-managed resource cleanup
for driver-less devices when they are released. However, when a device
link is created between the regulator and the port device, as part of
regulator_get(), the regulator takes a reference to the port device and
prevents it from being released unless regulator_put() is called, which
will never happen.

Avoid this by using the non-device-managed API and manually releasing
the regulator reference when the port is unregistered.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/phy/tegra/xusb-tegra124.c
drivers/phy/tegra/xusb-tegra186.c
drivers/phy/tegra/xusb-tegra210.c
drivers/phy/tegra/xusb.c
drivers/phy/tegra/xusb.h