Do not call platform_device_put if platform_device_alloc failed to allocate. Signed-off-by: Ladislav Michl <ladis@xxxxxxxxxxxxxx> --- arch/arm/mach-omap2/gpmc-nand.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c index f6ac027f3c3b..221c9d319880 100644 --- a/arch/arm/mach-omap2/gpmc-nand.c +++ b/arch/arm/mach-omap2/gpmc-nand.c @@ -126,17 +126,18 @@ int gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data, pdev = platform_device_alloc("omap2-nand", gpmc_nand_data->cs); - if (pdev) { - err = platform_device_add_resources(pdev, gpmc_nand_res, - ARRAY_SIZE(gpmc_nand_res)); - if (!err) - pdev->dev.platform_data = gpmc_nand_data; - } else { + if (!pdev) { err = -ENOMEM; + goto out_free_cs; } + + err = platform_device_add_resources(pdev, gpmc_nand_res, + ARRAY_SIZE(gpmc_nand_res)); if (err) goto out_free_pdev; + pdev->dev.platform_data = gpmc_nand_data; + err = platform_device_add(pdev); if (err) { dev_err(&pdev->dev, "Unable to register NAND device\n"); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html