diff options
author | Mathias Krause <minipli@googlemail.com> | 2014-04-15 01:58:15 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-04-16 11:11:47 -0400 |
commit | 9dc9cb0c9ad0f999e29ce4c4f307cd2abbe752d3 (patch) | |
tree | d5a2035c66129022df6981e1e1d1b67f3400cd1d /drivers/usb/phy/phy.c | |
parent | ae8dd0cc4146740e24ffb2092530c47e838001c5 (diff) |
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>
Diffstat (limited to 'drivers/usb/phy/phy.c')
-rw-r--r-- | drivers/usb/phy/phy.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index 8afa813d690b..36b6bce33b20 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c | |||
@@ -132,6 +132,9 @@ struct usb_phy *usb_get_phy(enum usb_phy_type type) | |||
132 | if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { | 132 | if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { |
133 | pr_debug("PHY: unable to find transceiver of type %s\n", | 133 | pr_debug("PHY: unable to find transceiver of type %s\n", |
134 | usb_phy_type_string(type)); | 134 | usb_phy_type_string(type)); |
135 | if (!IS_ERR(phy)) | ||
136 | phy = ERR_PTR(-ENODEV); | ||
137 | |||
135 | goto err0; | 138 | goto err0; |
136 | } | 139 | } |
137 | 140 | ||