From patchwork Sat Feb 11 13:02:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 9567973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4A59960572 for ; Sat, 11 Feb 2017 13:02:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 379C81FF1E for ; Sat, 11 Feb 2017 13:02:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2903328467; Sat, 11 Feb 2017 13:02:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABC9F1FF1E for ; Sat, 11 Feb 2017 13:02:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753467AbdBKNCO (ORCPT ); Sat, 11 Feb 2017 08:02:14 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:52408 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753435AbdBKNCO (ORCPT ); Sat, 11 Feb 2017 08:02:14 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23992136AbdBKNCNaKlqp (ORCPT ); Sat, 11 Feb 2017 14:02:13 +0100 Date: Sat, 11 Feb 2017 14:02:12 +0100 From: Ladislav Michl To: Roger Quadros Cc: Tony Lindgren , linux-omap@vger.kernel.org, Javier Martinez Canillas , Enrico Butera , Eduard Gavin , Enric Balletbo i Serra , =?iso-8859-2?Q?Agust=ED?= Fontquerni Subject: [PATCH 2/4] ARM: OMAP2+: gpmc-nand: fix error unwinding Message-ID: <20170211130212.cnyuxqczf5l33g6b@lenoch> References: <20160814084313.GA699@localhost.localdomain> <9706512a-a5ad-17c7-0867-4f592529fc8a@ti.com> <20160816185043.GA12255@localhost.localdomain> <20160817144922.3jwrwj67qjdsa2n7@atomide.com> <31d58234-8f57-b988-689a-bbcf6f56cb68@ti.com> <20170211125916.inojzppkuvsees2r@lenoch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170211125916.inojzppkuvsees2r@lenoch> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not call platform_device_put if platform_device_alloc failed to allocate. Signed-off-by: Ladislav Michl --- 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");