]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: phy: phy-mxs-usb: fix a possible NULL dereference
authorLABBE Corentin <clabbe.montjoie@gmail.com>
Thu, 12 Nov 2015 07:45:52 +0000 (08:45 +0100)
committerFelipe Balbi <balbi@ti.com>
Tue, 17 Nov 2015 17:35:48 +0000 (11:35 -0600)
of_match_device could return NULL, and so cause a NULL pointer
dereference later.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/phy/phy-mxs-usb.c

index 4d863ebc117c0f59cce46f39fda4d191e93b9843..b7536af777ab9c4f083d7b88ff2bfe093fca9e21 100644 (file)
@@ -452,10 +452,13 @@ static int mxs_phy_probe(struct platform_device *pdev)
        struct clk *clk;
        struct mxs_phy *mxs_phy;
        int ret;
-       const struct of_device_id *of_id =
-                       of_match_device(mxs_phy_dt_ids, &pdev->dev);
+       const struct of_device_id *of_id;
        struct device_node *np = pdev->dev.of_node;
 
+       of_id = of_match_device(mxs_phy_dt_ids, &pdev->dev);
+       if (!of_id)
+               return -ENODEV;
+
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(base))