From: Mathias Krause Date: Tue, 15 Apr 2014 05:58:15 +0000 (+0200) Subject: usb: phy: return an error in usb_get_phy() if try_module_get() fails X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9dc9cb0c9ad0f999e29ce4c4f307cd2abbe752d3;p=linux-beck.git 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 Signed-off-by: Felipe Balbi --- 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) if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { pr_debug("PHY: unable to find transceiver of type %s\n", usb_phy_type_string(type)); + if (!IS_ERR(phy)) + phy = ERR_PTR(-ENODEV); + goto err0; }