Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: phy: am335x: fix race condition in _probe

power off the phy should be done before populate the phy. Otherwise,
am335x_init() could be called by the phy owner to power on the phy first,
then am335x_phy_probe() turns off the phy again without the caller knowing
it.

Fixes: 2fc711d76352 ("usb: phy: am335x: Enable USB remote wakeup using PHY wakeup")
Cc: stable@vger.kernel.org # v3.18+
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

authored by

Bin Liu and committed by
Felipe Balbi
a53469a6 512e6fb5

+1 -4
+1 -4
drivers/usb/phy/phy-am335x.c
··· 61 61 if (ret) 62 62 return ret; 63 63 64 - ret = usb_add_phy_dev(&am_phy->usb_phy_gen.phy); 65 - if (ret) 66 - return ret; 67 64 am_phy->usb_phy_gen.phy.init = am335x_init; 68 65 am_phy->usb_phy_gen.phy.shutdown = am335x_shutdown; 69 66 ··· 79 82 device_set_wakeup_enable(dev, false); 80 83 phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, am_phy->dr_mode, false); 81 84 82 - return 0; 85 + return usb_add_phy_dev(&am_phy->usb_phy_gen.phy); 83 86 } 84 87 85 88 static int am335x_phy_remove(struct platform_device *pdev)