xhci: tegra: Prevent error pointer dereference
Quoted 22 lines · Greg Kroah-Hartman
Quoted 21 lines · Thierry Reding
From: Thierry Reding <[email protected]>
During initialization, the host and super-speed power domains will contain an
ERR_PTR()encoded error code rather than being NULL. To avoid a crash, use a !IS_ERR_OR_NULL() condition during cleanup.Signed-off-by Thierry Reding <[email protected]>--- drivers/usb/host/xhci-tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/usb/host/xhci-tegra.c +1
-1@@ -941,9 +941,9 @@ static void tegra_xusb_powerdomain_remove(struct device *dev,device_link_del (tegra->genpd_dl_ss);if (tegra->genpd_dl_host)device_link_del (tegra->genpd_dl_host); -if (tegra->genpd_dev_ss) +if (!IS_ERR_OR_NULL (tegra->genpd_dev_ss))
Quoted 8 lines
drivers/usb/host/xhci-tegra.c static void tegra_xusb_powerdomain_remove(struct device *dev, · line 948
Quoted 5 lines
drivers/usb/host/xhci-tegra.c +1
-1dev_pm_domain_detach (tegra->genpd_dev_ss, true); -if (tegra->genpd_dev_host) +if (!IS_ERR_OR_NULL (tegra->genpd_dev_host))dev_pm_domain_detach (tegra->genpd_dev_host, true); }Should this go to older kernels? If so, any hint as to what commit this "fixes:"?
Technically this:
which was merged into v4.20.
However, I have never seen this actually crash on current kernels and only came across it while working on a change to reset controls which can cause dev_pm_domain_attach_by_name() to fail. That function can't fail in current kernels, so I don't think we need to fix this in old kernels. So if we can get this into v5.0, that'd be good enough for me.
Thierry