mtd: nand: davinci: return ENOMEM if memory allocation is failed
authorIvan Khoronzhuk <ivan.khoronzhuk@ti.com>
Tue, 17 Dec 2013 13:36:05 +0000 (15:36 +0200)
committerBrian Norris <computersforpeace@gmail.com>
Fri, 3 Jan 2014 19:22:24 +0000 (11:22 -0800)
In case when memory allocation is failed the driver should return
ENOMEM instead of ENODEV.

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Taras Kondratiuk <taras@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/davinci_nand.c

index 584c1f4..4577fb4 100644 (file)
@@ -541,7 +541,7 @@ static struct davinci_nand_pdata
                                GFP_KERNEL);
                pdev->dev.platform_data = pdata;
                if (!pdata)
-                       return NULL;
+                       return ERR_PTR(-ENOMEM);
                if (!of_property_read_u32(pdev->dev.of_node,
                        "ti,davinci-chipselect", &prop))
                        pdev->id = prop;
@@ -598,6 +598,9 @@ static int nand_davinci_probe(struct platform_device *pdev)
        nand_ecc_modes_t                ecc_mode;
 
        pdata = nand_davinci_get_pdata(pdev);
+       if (IS_ERR(pdata))
+               return PTR_ERR(pdata);
+
        /* insist on board-specific configuration */
        if (!pdata)
                return -ENODEV;