Skip to content

Commit 2a4ea83

Browse files
jonhuntervinodkoul
authored andcommitted
phy: tegra: xusb: Fix crash during pad power on/down
Commit a88520b ("usb: gadget: tegra: Reduce pad power") added calls to tegra_phy_xusb_utmi_pad_power_on/down in the Tegra XUDC driver to control the pad power. This change is causing a kernel panic when powering down the pads on entering suspend with the Jetson TX2 platform. The panic occurs because the 'xudc->curr_utmi_phy' is not configured on this platform and we do not check to see if the pointer is valid before attempting to deference the pointer. Fix this by checking to see if the 'phy' pointer passed to tegra_phy_xusb_utmi_pad_power_on/down is valid. Fixes: a88520b ("usb: gadget: tegra: Reduce pad power") Signed-off-by: Jon Hunter <jonathanh@nvidia.com> Link: https://lore.kernel.org/r/20221010135132.30809-1-jonathanh@nvidia.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent ca1c736 commit 2a4ea83

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/phy/tegra/xusb.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,14 @@ EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_port_reset);
14611461

14621462
void tegra_phy_xusb_utmi_pad_power_on(struct phy *phy)
14631463
{
1464-
struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
1465-
struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1464+
struct tegra_xusb_lane *lane;
1465+
struct tegra_xusb_padctl *padctl;
1466+
1467+
if (!phy)
1468+
return;
1469+
1470+
lane = phy_get_drvdata(phy);
1471+
padctl = lane->pad->padctl;
14661472

14671473
if (padctl->soc->ops->utmi_pad_power_on)
14681474
padctl->soc->ops->utmi_pad_power_on(phy);
@@ -1471,8 +1477,14 @@ EXPORT_SYMBOL_GPL(tegra_phy_xusb_utmi_pad_power_on);
14711477

14721478
void tegra_phy_xusb_utmi_pad_power_down(struct phy *phy)
14731479
{
1474-
struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
1475-
struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1480+
struct tegra_xusb_lane *lane;
1481+
struct tegra_xusb_padctl *padctl;
1482+
1483+
if (!phy)
1484+
return;
1485+
1486+
lane = phy_get_drvdata(phy);
1487+
padctl = lane->pad->padctl;
14761488

14771489
if (padctl->soc->ops->utmi_pad_power_down)
14781490
padctl->soc->ops->utmi_pad_power_down(phy);

0 commit comments

Comments
 (0)