phy: phy-mvebu-sata: Add missing error check for devm_kzalloc
authorPeter Griffin <peter.griffin@linaro.org>
Fri, 15 Aug 2014 12:40:09 +0000 (13:40 +0100)
committerKishon Vijay Abraham I <kishon@ti.com>
Wed, 24 Sep 2014 09:48:31 +0000 (15:18 +0530)
Currently this driver is missing a check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.

This patch adds the aformentioned missing check.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Acked-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/phy/phy-mvebu-sata.c

index cc3c0e166dafba9e90241ff71c604d24ac351392..10bb8e5aa94062aeedb9e42ada9edba64c7588ba 100644 (file)
@@ -89,6 +89,8 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
        struct phy *phy;
 
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        priv->base = devm_ioremap_resource(&pdev->dev, res);