2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 12:14:01 +08:00
linux-next/drivers/phy/tegra
Thierry Reding e78fdbad1e phy: tegra: Don't use device-managed API to allocate ports
The device-managed allocation API doesn't work well with the life-cycle
of device objects. Since ports have device objects allocated within, it
can lead to situations where these devices need to stay around until
after their parent pad controller has been unbound from its driver. The
device-managed memory allocated for the port objects will, however, get
freed when the pad controller unbinds from the driver. This can cause
use-after-free errors down the road.

Note that the device is deleted as part of the driver unbind operation,
so there isn't much that can be done with it after that point, but the
memory still needs to stay around to ensure none of the references are
invalidated.

One situation where this arises is when a VBUS supply is associated with
a USB 2 or 3 port. When that supply is released using regulator_put() an
SRCU call will queue the release of the device link connecting the port
and the regulator after a grace period. This means that the regulator is
going to keep on to the last reference of the port device even after the
pad controller driver was unbound (which is when the memory backing the
port device is freed).

Fix this by allocating port objects using non-device-managed memory. Add
release callbacks for these objects so that their memory gets freed when
the last reference goes away. This decouples the port devices' lifetime
from the "active" lifetime of the pad controller (i.e. the time during
which the pad controller driver owns the device).

Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-03-19 14:00:05 +01:00
..
Kconfig phy: tegra: xusb: Add usb-role-switch support 2020-03-19 13:54:35 +01:00
Makefile phy: tegra: xusb: Add Tegra194 support 2020-03-19 13:59:46 +01:00
phy-tegra194-p2u.c phy: tegra: Add PCIe PIPE2UPHY support 2019-08-13 16:01:15 +01:00
xusb-tegra124.c phy: tegra: Don't use device-managed API to allocate ports 2020-03-19 14:00:05 +01:00
xusb-tegra186.c phy: tegra: Don't use device-managed API to allocate ports 2020-03-19 14:00:05 +01:00
xusb-tegra210.c phy: tegra: Don't use device-managed API to allocate ports 2020-03-19 14:00:05 +01:00
xusb.c phy: tegra: Don't use device-managed API to allocate ports 2020-03-19 14:00:05 +01:00
xusb.h phy: tegra: Don't use device-managed API to allocate ports 2020-03-19 14:00:05 +01:00