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

usb: phy: return an error in usb_get_phy() if try_module_get() fails

In case we found a matching USB PHY in usb_get_phy() but the call to
try_module_get() fails, we shouldn't return a (probably soon dangling)
pointer but an ERR_PTR instead.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Mathias Krause and committed by
Felipe Balbi
9dc9cb0c ae8dd0cc

+3
+3
drivers/usb/phy/phy.c
··· 132 132 if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { 133 133 pr_debug("PHY: unable to find transceiver of type %s\n", 134 134 usb_phy_type_string(type)); 135 + if (!IS_ERR(phy)) 136 + phy = ERR_PTR(-ENODEV); 137 + 135 138 goto err0; 136 139 } 137 140