From patchwork Thu May 15 19:24:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Goode X-Patchwork-Id: 349345 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B972814009E for ; Fri, 16 May 2014 05:28:11 +1000 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wl1H0-0006Nx-Dr; Thu, 15 May 2014 19:24:58 +0000 Received: from mail-la0-x22c.google.com ([2a00:1450:4010:c03::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wl1Gx-0006Hg-Hj for linux-arm-kernel@lists.infradead.org; Thu, 15 May 2014 19:24:56 +0000 Received: by mail-la0-f44.google.com with SMTP id hr17so1183335lab.31 for ; Thu, 15 May 2014 12:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=NoVfjkdK7zuLzaQLPm/W/7g9HhYIfuAU7PtyXaD1HQQ=; b=aU2Vsiig9C/uAOQOqfJgKHu/cprAB7ucAZo1iP4grXWss/+TUmSHu2wZzeIsYAHAEI T9yWz5mez2n8p0HKcsluoDdkhm5Wx8X9PtyYLrYJQ86eq6sEuwhbj6D7S2EThFh64i3U ZpdZ6PbLzWM6buDyX82fcEsdMp80uMZcWwpGvoRO2h1KAej3r314rb6w7vwXq3luzGnS 7yPgRdBklq/FwUZeVIzr+zO9iJa200v/LcTEagBCjHv04VGAIws6sm8k+YWl6gc0oI+t +zV9Fj4xUQmCEvAd4qsHgnNewmjdCYd51P9BTP+jx2Ets4ZuwOr8OGik6cLgcbO3MCVH 8+zQ== X-Received: by 10.152.198.129 with SMTP id jc1mr2710420lac.63.1400181872699; Thu, 15 May 2014 12:24:32 -0700 (PDT) Received: from lianli.example.org (s83-179-48-77.cust.tele2.se. [83.179.48.77]) by mx.google.com with ESMTPSA id d8sm7106213lah.12.2014.05.15.12.24.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 May 2014 12:24:31 -0700 (PDT) From: Emil Goode To: Shawn Guo , Sascha Hauer , Russell King Subject: [PATCH] ARM: imx: clean up error handling Date: Thu, 15 May 2014 21:24:30 +0200 Message-Id: <1400181871-10325-1-git-send-email-emilgoode@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140515_122455_767823_CC4BB39C X-CRM114-Status: GOOD ( 12.82 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (emilgoode[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Cc: Emil Goode , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org If we fail to allocate struct platform_device pdev we dereference it after the goto label err. I have rearranged the error handling a bit to fix the issue and also make it more clear. Signed-off-by: Emil Goode --- arch/arm/mach-imx/devices/platform-ipu-core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-imx/devices/platform-ipu-core.c b/arch/arm/mach-imx/devices/platform-ipu-core.c index fc4dd7c..14d61d9 100644 --- a/arch/arm/mach-imx/devices/platform-ipu-core.c +++ b/arch/arm/mach-imx/devices/platform-ipu-core.c @@ -77,34 +77,38 @@ struct platform_device *__init imx_alloc_mx3_camera( pdev = platform_device_alloc("mx3-camera", 0); if (!pdev) - goto err; + return ERR_PTR(ret); pdev->dev.dma_mask = kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL); if (!pdev->dev.dma_mask) - goto err; + goto put_pdev; *pdev->dev.dma_mask = DMA_BIT_MASK(32); pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res)); if (ret) - goto err; + goto free_dma_mask; if (pdata) { struct mx3_camera_pdata *copied_pdata; ret = platform_device_add_data(pdev, pdata, sizeof(*pdata)); - if (ret) { -err: - kfree(pdev->dev.dma_mask); - platform_device_put(pdev); - return ERR_PTR(-ENODEV); - } + if (ret) + goto free_dma_mask; + copied_pdata = dev_get_platdata(&pdev->dev); copied_pdata->dma_dev = &imx_ipu_coredev->dev; } return pdev; + +free_dma_mask: + kfree(pdev->dev.dma_mask); +put_pdev: + platform_device_put(pdev); + + return ERR_PTR(ret); } struct platform_device *__init imx_add_mx3_sdc_fb(