usb: phy: return an error in usb_get_phy() if try_module_get() fails
authorMathias Krause <minipli@googlemail.com>
Tue, 15 Apr 2014 05:58:15 +0000 (07:58 +0200)
committerFelipe Balbi <balbi@ti.com>
Wed, 16 Apr 2014 15:11:47 +0000 (10:11 -0500)
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>
drivers/usb/phy/phy.c

index 8afa813d690bc6f7aa15c9b9c7523cf96b24099a..36b6bce33b20c17df4583e5ce5e9b07298335842 100644 (file)
@@ -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;
        }
 
This page took 0.026202 seconds and 5 git commands to generate.